Re: editing an entry ,how to call the form action

2010-02-08 Thread jimgardener
thanks rebus
-jim
>
> 
> {{entryform.as_ul }}
> 
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: editing an entry ,how to call the form action

2010-02-08 Thread rebus_
Opps, for you view context it should be "entryform" not "form":


{{entryform.as_ul }}

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: editing an entry ,how to call the form action

2010-02-08 Thread rebus_
On 8 February 2010 16:52, jimgardener  wrote:
> hi
> I created a view function to edit an entry.
> def edit_entry(request,id):
>        entry=get_object_or_404(MyEntry,id=id)
>        if request.method=='POST':
>                form=MyEntryForm(request.POST,instance=entry)
>                if form.is_valid():
>                        form.save()
>                        redirect('myapp_entry_archive_index')
>        else:
>                form=MyEntryForm(instance=entry) #for GET method and invalid 
> forms
>
>        return render_to_response('myapp/myentry_edit_entry.html',
> {'entryform':form})
>
> then I created the urls like
> url(r'^editentry/(?P\d+)/
> $','myapp.views.edit_entry',name='myapp_edit_entry'),
>
> My problem here is how I should give the action in form in the
> template.
> I tried
> 
> {{entryform.as_ul }}
> 
> 
>
> But since the /myapp/editentry/ doesn't match any urls ,it gives a
> 404. How should I pass the id  of entry(which is to be edited) to
> action?
>
> I know this is a silly doubt..But I am a newbie to web programming..If
> anyone can help please do
>
> jim
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

Depends on the way you included your app url.py in projects urls.py.

If in your project's urls.py you have included your apps urls like
url(r'^myapp/$', include('myapp.urls')), then your URL would look like
/myapp/editentry/1/

And instead of hard-coding action url in the template try using
built-in url template tag:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

For example:


{{entryform.as_ul }}



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.