> What I want to do is creating a title based on what I write in the
> ForeignKey field before creating the category so it can be used
> immediately.
You can do just that. Just accept the title in a CharField, without a choices= option, and then create the Title based on that, then creating the category to refer to it. The code would look something like this:
t = Title(title=form.cleaned_data['title'])
t.save()
# This creates the primary key for the new Title object
c = Category(title=t)
c.save()
You can add appropriate checks if the title and category already exist, to handle those the way you wan tto.
--
-- Christophe Pettus
xof@thebuild.com
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment