0

I am trying to implement a restaurant chief website.

So basically, I have States, Cities, Restaurants and Chiefs.

Class State(models.Model):
   name = models.CharField(max_length=30)

Class City(models.Model):
   name = models.CharField(max_length=30)
   state = models.ForeignKey(State)

class Restaurant(models.Model):
   name = models.CharField(max_length=30)
   state = models.ForeignKey(City)

class Chief(models.Model):
   name = models.CharField(max_length=30)
   restaurant = models.ForeignKey(Restaurant)

Rules:

  • States and city relations are fixed. A city cannot move to another state. But new states and city may be added.

  • A restaurant can move to another city.

  • A chief can move to another restaurant.

  • A restaurant can have more than one chiefs.

1) Is this a correct model?

2) I upload some of the data via admin form, and some from fixtures, but sometimes when I need to change a Chief to another restaurant in a different state it causes problem when I try to view the website (manage.py loaddata fixture works fine) . But there is no problem with changing to a different restaurant within the same city.

I am open to any practical MySQL/Django book suggestions.

Emmet B
  • 5,341
  • 6
  • 34
  • 47
  • What do you mean by "causes problems"? Is there some specific exception? How are you changing the Chief to a different restaurant? – csinchok Jan 16 '13 at 06:51
  • It was giving some problems. I deleted the database, and created it from scratch again. Seems fine now. – Emmet B Jan 16 '13 at 10:24

0 Answers0