Default value for field in Django model
- by Daniel Garcia
Suppose I have a model:
class SomeModel(models.Model):
id = models.AutoField(primary_key=True)
a = models.IntegerField(max_length=10)
b = models.CharField(max_length=7)
Currently I am using the default admin to create/edit objects of this type. How do I set the field 'a' to have the same number as id? (default=???)
Other question
Suppose I have a model:
event_date = models.DateTimeField( null=True)
year = models.IntegerField( null=True)
month = models.CharField(max_length=50, null=True)
day = models.IntegerField( null=True)
How can i set the year, month and day fields by default to be the same as event_date field?