django - Storing restaurant categories in GeoDjango project -
i making geo django backend iphone app. iphone app sends users current location backend, returns nearby restaurants (something similar foursquare , yelp.)
i not exclusively sure how store cuisine restaurants. need alternative user can up/select specific cuisine illustration chinese food. should create seperate model restaurant cuisine , have 1 many relationship restaurants ? or should utilize boolean value this:
models.booleanfield(default=false) here code model:
from django.db import models django.contrib.gis.db import models gis_models django.contrib.gis import geos django.db import models # create models here. class restaurant(models.model): name = models.charfield(max_length = 100) address = models.charfield(max_length = 150) phone = models.charfield(max_length = 12) cuisine = models.charfield(max_length = 50) eatingoptions = models.charfield(max_length = 50) location = gis_models.pointfield(u'latitude/longitude', geography=true, blank=true, null=true) # query manager gis = gis_models.geomanager() objects = models.manager() def __unicode__(self): homecoming self.name
only , requirements can reply that.
if create separate model , have relationship more flexible, can have different cuisines without changing model. best alternative if database have multiple types of cuisine. if take utilize booleanfield is_chinese work chinese cuisine. best alternative if care 1 type of cuisine.don't worry if create bad judgement when developing (at to the lowest degree on stage), django has back.
hope helps.
django database-design django-models
No comments:
Post a Comment