Another n00b question: How do I get a new record's PK after save()?
If I have:
class Foo(models.Model):
Foo_ID = models.IntegerField(primary_key=True, editable=False)
Foo_Text = models.CharField(blank=True, maxlength=150)
And I have a view that contains something like:
if request.method == 'POST':
f = FooForm(request.POST)
if f.is_valid():
f2 = f.save(commit=False)
f2.save()
>From what I've been reading it looks like I should be able to get the
new record's PK with:
f2.id
or maybe
f2.Foo_ID
But no joy. The result is either None or an error message that Foo has
no attributes id. FWIW, the record is created and it has a PK.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---