Sunday, September 21, 2014

Re: new to django data modeling for an application

class Person(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField()

    def __str__(self):
        return self.name


class Restaurant(models.Model):
    name = models.CharField(max_length=100)
    adress = models.CharField(max_length=200)

    def __str__(self):
        return self.name


class Dish(models.Model):
    restaurant = models.ForeignKey(Restaurant)
    name = models.CharField(max_length=200)
    description = models.TextField()

    def __str__(self):
        return self.name

should i connect some how the person to the restaurant?


On Thursday, September 18, 2014 5:17:17 PM UTC-5, dk wrote:
i did the django tutorial  and to get a better grasp i decided to make a webpage.  with 2 sections

section 1
every day will let the user vote for a restaurant before 4pm

section 2
from the restaurant with more votes will display the menu of the restaurant  and each user can chose what they want for dinner.
that way the admin of the restaurant can just print that list every day =)

and if some one ask me for information, 
i would like to be able to tell them,
a date, what restaurant was choosen, how many votes, and the selection of the users.
maybe they want to know whats the most popular restaurant, or the food that more people select from a particular restaurant

(this was very easy in my head till i got to thing on the data base tables and how they should be connected)

so first things first.

i made my django project,
added an application call poll

in here i should have my
restaurant table with a choise list of the restaurants that can be chosen.

and after that should be another table with the dishes. where the forgen key is the restaurant???
how i do this one?

thaks guys.












--
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/c300d469-5d6f-41f2-8b9f-7debdeb3bb8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment