[Answered ]-Auto populate DateTimeField not working in django forms



I think the error is because you’re adding the auto_now_add extra argument to your form instead of to your mode. Try changing your model to the following to see if that fixes the problem (untested):

class Users(models.Model):
  name = models.CharField(max_length = 100)
  role = models.ForeignKey(RolesConfig, db_column = 'role')
  level = models.ForeignKey(LevelConfig, db_column = 'level')
  team_name = models.ForeignKey(TeamNamesConfig, db_column = 'team_name')
  location = models.ForeignKey(LocationConfig, db_column = 'location')
  modified = models.DateTimeField(auto_now = True)
  class Meta:
     db_table = u'users'
     def __str__(self):
            return "%s" % (self.ldap)
     def __unicode__(self):
     return u'%s' % (self.ldap)
πŸ‘€rolling stone

Leave a comment