I am not sure of how or the best way to structure my data in models.py. I would like to have an order and allow multiple items / products to be added to an order. I know I can do a ManyToMany field but not sure how I would connect a qty to that. I am sure there is some simple way of doing this, or a better way to model the data. I know in many ERP systems they have an orders table and then an orders details table. Below is just a quick mock-up of how i was thinking on to do it until I started thinking about the many items and qty to an single order issue came up. Can any one give me some tips on how to accomplish this?
class Item(models.Model):
name = models.CharField(max_length200)
description = models.TextField(blank=True)
def __unicode__(self):
return self.name
class Customer
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
address = models.CharField(max_length=200)
def __unicode__(self):
return self.name
class order(models.Model):
order = models.IntegerField(unique=True)
customer = models.ForeignKey('Customer')
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment