django - why would my databse entries be coming up empty? -
django - why would my databse entries be coming up empty? -
i'm trying create new instances based off of form below when saves, database saves foreign key value , order value nil else. thought why?
models:
class dancetype(models.model): eventtype = models.foreignkey(comptype) dance_name = models.charfield(max_length = 20) cost = models.floatfield(max_length = 7, null=true, blank=true ) field_2 = models.charfield(max_length = 20, null=true, blank=true) def __unicode__(self): fields = ('field_2') homecoming self.dance_name class dancer(models.model): dancetype = models.foreignkey(dancetype) e_number = models.integerfield(max_length = 4, null=true, blank=true) d1_first_name = models.charfield(max_length = 20) d1_last_name = models.charfield(max_length = 20) d1_email = models.emailfield(max_length = 20) city = models.charfield(max_length = 20) order = models.positiveintegerfield() perform = models.nullbooleanfield(null=true, blank=true)
view:
if request.method =='post': sub_type = request.post.get("form") dancetype = request.post.get("dancetype") ext = request.post.get("quantity") form = modelformset_factory(dancer, form=compreg, extra=int(ext)) productform = form(queryset = dancer.objects.none()) if sub_type == "submitted": productform = form(request.post, request.files) if productform.is_valid(): p in productform: dance=p.save(commit=false) dance.dancetype_id = 4 dance.order = 1 dance.save() else: der = "it didnt save"
django django-models django-forms
Comments
Post a Comment