Monday, 15 September 2014

python - Django Admin - Unable to change Foreign Key field -



python - Django Admin - Unable to change Foreign Key field -

i have django version 1.4.5

here relevant parts of model

class product (models.model): name=models.charfield(max_length=200) description=models.textfield() label=models.foreignkey('label') pub_date = models.datetimefield(editable=false) def save(self): #item not have id if first save if not self.id: self.pub_date = datetime.date.today() super(product, self).save() def __unicode__(self): homecoming self.name class label(models.model): """ clothing label, e.g. kate spade """ name=models.charfield(max_length=100) def __unicode__(self): homecoming self.name

when effort publish product, selecting label works fine. publishing item works expected, , label field remains populated upon returning product in admin console. however, if effort alter value of label field, taken default list of products page, message "he product "prod 1" changed successfully" returning prod 1 page reveals field wasn't saved properly.

any ideas here?

super(product, self).save() within if block, isn't beingness called on edits. also, why not utilize auto_now_add on pub_date field?

python django django-models django-admin

No comments:

Post a Comment