This may be a lame question, but how do I use the primary key as a default value for an attribute?
This is my models.py:
class Thread(models.Model):
thread_pk = models.PositiveIntegerField(default=self.pk)
This gives me an error:
self is not defined
How do I go about using the pk as a default value of an attribute? Any help will be grateful. Thank you.
-- This is my models.py:
class Thread(models.Model):
thread_pk = models.PositiveIntegerField(default=self.pk)
This gives me an error:
self is not defined
How do I go about using the pk as a default value of an attribute? Any help will be grateful. Thank you.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHSNPWs3NSQtzciqYL%2B7C7FL3Ybu1SAQv-L73EL2DNCMpJn7tA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment