Friday, February 4, 2011

forms and models

I have the following code:
def sites(request):
if 'url' in request.GET:
url = request.GET['url']

website = WebSite.objects.get( url = url )
form = WebSiteForm(instance = website)

return submit_web_form( request, form )
else:
form = WebSiteForm(request.POST)
if not form.is_valid():
return submit_web_form(request, form)

....

It always come back invalid, and when if feed it back it displays the
error that "name" already exists.
I know it exist, but I want to edit the existing model. Do I have to
load in the data separately
like data = {'name':'blabla.com .... and then form =
WebSiteForm( data ) or can I use the instance.

--
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