I would say first that there's more than one way to skin this cat.  So
if what you're doing works for your team and your users, stick with
it.

Regarding RESTful URLs, my understanding is that the URL is the noun
and the request method is the verb.  E.g.,

http://example.com/somepage/ is your thing (the noun), and you can
GET, POST, PUT, and DELETE that thing via the HTTP protocol.

Since browsers only support GET and POST, you end up having to deal
with PUT and DELETE in another way.  You can make it a part of the url
(http://example.com/somepage/delete/), or you can make it a query
parameter to the URL (http://example.com/somepage/?action=DELETE).  No
right way, necessarily, but I prefer the first as it's more 'user/
human' friendly then the second.  Either way, that request should be a
POST as it changes data on the server.

Typically in Django, you'll see http://example.com/somepage/ coded to
display a resource when it's accessed via GET, and edited/changed when
accessed via POST.  Ideally, you should only be changing data server
side with POSTs, as GETs should be idempotent (they don't change data)
according to the HTTP spec.

Like you said, you can be as religious about this as you want, but at
the end of the day, getting something functional to the user is all
that really matters (many of them don't even look at the URLs).


doug.

On Jun 18, 10:31 pm, Vasiliy Gladkov <[EMAIL PROTECTED]> wrote:
> urls.py for my application looks like this:
>
> urlpatterns = patterns('ms.masterstroy.views',
>         (r'^(?P<title>[^/]+)$', 'page'),
>         ...
> )
>
> As i want to allow site editor to edit pages in convenient way without
> built-in django admin, i use request.GET parameters like "http://
> localhost:8000/somepage?action=edit" and than process it in my
> views.py like this:
>
> def page(request, title):
>   page = Page.objects.get(url_name=title)
>   ...
>   if 'action' in request.GET:
>     action = request.GET['action']
>     if action == 'delete':
>       target_name = request.GET.get('target', '')
>       target_page = get_object_or_404(Page, url_name=target_name)
>       target_page.delete()
>       return http.HttpResponseRedirect('/')
>     if action == 'edit':
>       .... and so on...
>
> A lot of people from russian django group (http://groups.google.com/
> group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
> language) told me that it's very bad decision as im losing some
> important django advantages.
>
> What they talking about? I have no idea. I have clear and simple urls
> and my urls is much closer to REST princeiples then django admin site
> with all this "http://localhost:8000/admin/my_cms/page/4/delete/"; wich
> is not REST at all. Btw, REST is kind of religion so you can follow it
> or you can not. I just dont want to have large trees of url-patterns
> in my urls.py and move all actions with my model in one view with a
> couple of "if action == ...: elseif action ==..."
>
> And i still can use url reversing in my templates like "{% url page
> 'pagename' %}?action=edit"
>
> So, what is the problem?
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to