Opened 10 years ago

Closed 10 years ago

#22968 closed Uncategorized (invalid)

can not get primary key after insert

Reported by: khaihkd Owned by: nobody
Component: Uncategorized Version: 1.6
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

Example, in database mysql, I have a table

User(id: integer primary key AUTO INCREMENT, name: string)

When I create new record

user = User()
user.name = "This is name"
user.save()

=> success

I can not get user id

print(user.id) => none
print(user.pk) => none

=> How to get it? Please help me. Thank you very much

Change History (1)

comment:1 by Simon Charette, 10 years ago

Resolution: invalid
Status: newclosed

Hi and welcome,

This place is for reporting issues against Django itself. If you need help, you should ask on IRC or on the django-users mailing list.

See here: ​https://docs.djangoproject.com/en/1.6/faq/help/

Thanks.

Note: See TracTickets for help on using tickets.
Back to Top