Alright, perhaps my description of the problem was not very clear. Hadn't gone back to it, but using "initial" when creating form solved the problem.
On Wed, Sep 2, 2009 at 1:56 PM, Rochak Neupane <kah...@gmail.com> wrote: > Taking the Book and Author example from > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ > > > When creating a book, I would like to add an author if no such author exists. > > I believe by default > > class BookForm(ModelForm): > > class Meta: > model = Book > > > displays "Author" as a drop down, but I want to make it a text box, and then > add the author from there, so as to avoid the situation where an author must > be created before a book can be created. > > > I modified BookForm so that author is now a char field. When a new form is > submitted, I try to get author for the given name, if they don't exist, I > create the author and then go on to adding the book. Adding works ok. It is > when I edit that I'm confused about. > > > When I go to edit book form, author field is empty! So before rendering the > edit, I get an instance of author and added it to the form, but no luck. > > > Any suggestions? > > > thanks! > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---