I have a question on django model. I want to create a magazine model
that allow admin to add gadget, sport articles. And there are classes
for gadget, sport and food for adding only that specific article. How
to model this? I read through one to one field and many to many field.
I just could not get the magazine model right. Please guide.

Magazine
- sport (tennis)
- food (fast food)
- sport (swimming)
- food (sushi)

Sport
- tennis (sportA, sportC)
- swimming (sportB, sportC)

Food
- fast food (foodA, foodB)
- sushi (foodB, foodC)

class Food(models.Model):
    name = models.CharField(max_length=100)

class FoodList(models.Model):
    title = models.CharField(max_length=30)
    foods = models.ManyToManyField(Food, blank=True)

class Sport(models.Model):
    name = models.CharField(max_length=100)

class SportList(models.Model):
    title = models.CharField(max_length=30)
    sports = models.ManyToManyField(Sport, blank=True)

class Magazine(models.Model):
    sportList = models.OneToOneField(SportList)
sportList = models.OneToOneField(SportList)



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to