Tuesday, January 28, 2014

Django models design for ride share application

I am working on a ride share application. I need help on designing the models for private messages.

I have designed the below models, its look like complex in querying them in views. can you guys help me in design a better and easy one!

  class Ride(models.Model):         type = models.BooleanField(default=False)      add_source = models.ForeignKey(Address, related_name='source')      add_destination = models.ForeignKey(Address, related_name='destination')      ride_startDateTime = models.DateTimeField(default= datetime.datetime.now, blank=True)      ride_startPref = models.CharField(max_length=10, choices=CHOICES, default='None')    class Conversation(models.Model):      ride_id = models.ForeignKey(Ride)    class Messages(models.Model):      conversation_id = models.ForeignKey(Conversation)      ride_id = models.ForeignKey(Ride)      sender_id = models.ForeignKey(User, related_name='sender')      receiver_id = models.ForeignKey(User, related_name='receiver')      Content = models.TextField(max_length=1000,blank=True)      timestamp = models.DateTimeField(default= datetime.datetime.now, blank=True)      status = models.CharField(max_length=10,blank=True)

User model is django inbuilt. Please consider the following use cases:

1) A Conversation has to integrate with Ride, For Ex: User X is a owner of ride 3, User Y can contact X for this ride(3), then the new conversation id(77) will be generated. After that whatever messages sent between them should be under the same conversation id(77). If another user Z is trying to contact the user X for the same ride 3, then a new conversation ID(33) has to generated.

2) If the user X having another ride called 4, then if user Y contact the User X through the other ride means, it has to generate new conversation id(99) and all the messages sent between them on the ride should come under the same conversation id(99).


--
With regards,

Kannan. R. P,
Blog @: http://kannan4k.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL4xV_BpNS1%3DQN1aaugBDbDyQ0TCTf3cMc2YRjWd21A%3DYT8XLg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment