Default value for hidden field in Django model
Posted
by Daniel Garcia
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Garcia
Published on 2010-05-06T20:08:43Z
Indexed on
2010/05/06
20:58 UTC
Read the original article
Hit count: 417
I have this Model:
class Occurrence(models.Model):
id = models.AutoField(primary_key=True, null=True)
reference = models.IntegerField(null=True, editable=False)
def save(self):
self.collection = self.id
super(Occurrence, self).save()
I want for the reference field to be hidden and at the same time have the same value as id. This code works if the editable=True but if i want to hide it it doesnt change the value of reference.
how can i fix that?
© Stack Overflow or respective owner