I'm sure I'm missing something simple here, since its a common flow -
1.) e.g. model Person - has 4 fields -
person_id = models.AutoField(primary_key=True)
person_name = models.CharField(max_length=50)
comments = models.TextField(blank=True)
create_dt = models.DateTimeField(auto_now_add=True)
modify_dt = models.DateTimeField(auto_now_add=True)
class Meta:
unique_together = ("person_id", "person_name")
2.) When I save a new person, everything works normal, since I'm
giving -
p1 = Person(person_id=None, person_name=personNameArg,
comments=pComment)
3.) After this save is performed, I have the "person_id" of this
person. When someone hits save again, I do this -
p1 = Person(person_id=personIdArg, person_name=personNameArg,
comments=pComment)
where personIdArg is the earlier saved id.
I get the error - "create_dt cannot be Null", I see that dJango is
correctly trying to update, but since I didn't pass create_dt, it is
setting it to NULL in the update query.
I just want it to be left alone, since it already has a value. Is
there a way to tell django to not touch these fields ?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---