On 4 mai 09, at 06:54, scott212 <scottwill...@gmail.com> wrote:
> I'm reading through the djangobook and trying to build a small app as
> I go. The app is just a list that I can add to and delete entries
> from. Deleting is easy, but I'm not sure how the url/view portion
> should be handled.
>
> http://127.0.0.1:8080/lists/show/
>
> list item 1 - [delete]
> list item 2 - [delete]
> list item 3 - [delete]
>
> When an item is deleted, I would just like it to return to the same
> url. The way I'm seeing to do it would leave a somewhat ugly and
> irrelevant url (lists/delete/item1) while viewing the list. What's a
> more proper way to do this?
>
> #urls.py
>
> urlpatterns = patterns('',
>        (r'^lists/show/$', showItems),
>        (r'^lists/delete/([^/]+)$', deleteItem)
> )
>
>
> #views.py
>
> def showItems(request):
>    # get the items from the model
>    return render_to_response('lists/show.html', {'items':items})
>
> def deleteItems(request, item):
>    # delete the item
>    return render_to_response('lists/show.html', {'items':items})
>
HttpResponseRedirect and reverse().



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

Reply via email to