Opened 9 years ago

Last modified 9 years ago

#25343 closed Bug

pk attribute not set when having own primary key — at Version 1

Reported by: eng. Ilian Iliev Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by eng. Ilian Iliev)

Example:

# models.py
class Language(models.Model):
    language = models.IntegerField(primary_key=True)
    code = models.CharField(verbose_name='Language code (2 chars)', blank=False, max_length=2)

# views.py
l = Language.objects.create(code='x')
print l.pk  # return None

The above mention problem happens only if we have "primary_key=True" otherwise it works as expected.

Change History (1)

comment:1 by eng. Ilian Iliev, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top