Thank you for your prompt reply Daniel!

Let me clarify by detailing the example provided above:

In my hypothetical form "formexample" on my hypothetical page "time/
plus/3/", do you agree that if I put a relative URL in the action
field, like: action="myscript" it will eventually trigger a call to
"time/plus/3/myscript"?

While I would (naturally, imho) expect a call to "myscript"?

An example replacing slashes by underscores may help to better
understand:

"formexample" is now inside a page called "time_plus_3/". The action
field still points to "myscript". Then I get the correct behavior.

I hope I was convincing enough to highlight what seems to me a BIG
problem, but may be I am just either too picky or a bit silly. BIG
problem because it prevents people from easily relocating the web app
as it becomes tied to its prefix when using an absolute url.

But I need to have a look at the {% url %} tag, that could solve my
existential problem. Thanks for the hint.

On Mar 18, 1:13 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Friday, March 18, 2011 10:34:03 AM UTC, Christophe wrote:
>
> > Hi All,
>
> > I did not find anything about that topic so I am probably missing one
> > big thing here. I would be really glad to have your opinion so first
> > let me start by quoting the Djangobook:
>
> > """
> > A Word About Pretty URLs
>
> > If you’re experienced in another Web development platform, such as PHP
> > or Java, you may be thinking, “Hey, let’s use a query string
> > parameter!” — something like /time/plus?hours=3, in which the hours
> > would be designated by the hours parameter in the URL’s query string
> > (the part after the ?).
>
> > You can do that with Django (and we’ll tell you how in Chapter 7), but
> > one of Django’s core philosophies is that URLs should be beautiful.
> > The URL /time/plus/3/ is far cleaner, simpler, more readable, easier
> > to recite to somebody aloud and … just plain prettier than its query
> > string counterpart. Pretty URLs are a characteristic of a quality Web
> > application.
> > """
>
> > So my question is: assuming you have a form within the view triggered
> > by the "/time/plus/3/" call, how do you avoid putting an absolute path
> > in the form action field? All that because of slashes in the calling
> > url. That is so, so, so ugly that it deprecates completely the
> > advantage of having nice urls based on slashes. Or am I missing
> > something?
>
> > Of course having the root url in a global parameter is not an option
> > if we stick to prettiness requirement. Using something else than a
> > slash as a special character may be?
>
> > Many thanks for sharing your opinion!
>
> I don't understand your problem at all. Why does the structure of the URL
> change in any way what you put into the form action field?
>
> Usually in Django, as in many other frameworks, forms post to the same URL
> as they were originally served from, and the view distinguishes between GET
> and POST in order to process them correctly. This means that you usually
> just put "." as the form's action.
>
> Additionally, Django discourages putting hard-coded urls into templates in
> any case, in favour of dynamically-calculated ones via the {% url %} tag.
> --
> DR.

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