url tag

0 views
Skip to first unread message

Kenneth Gonsalves

unread,
May 28, 2009, 2:54:36 AM5/28/09
to fosscon...@googlegroups.com
hi,

@theju. I noticed that you have put in the url tag in the templates. The only
problem is that previously we had a '/web/' prefix to all the views. Now that
is not there. For example, postsfull used to be:

/web/postsfull/2/

now it is:
/postsfull/2/

this should be reflected when using the url tag. Am trying to figure out where
to make the change - if you can please do it.
--
regards
kg
http://lawgon.livejournal.com

Thejaswi Puthraya

unread,
May 28, 2009, 1:26:40 PM5/28/09
to fossconf-devel
Hi,

On May 28, 11:54 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> hi,
>
> @theju. I noticed that you have put in the url tag in the templates. The only
> problem is that previously we had a '/web/' prefix to all the views. Now that
> is not there. For example, postsfull used to be:
>
> /web/postsfull/2/
>
> now it is:
> /postsfull/2/
>
> this should be reflected when using the url tag. Am trying to figure out where
> to make the change - if you can please do it.

I think you have not understood the reason for using the url tag.

Let me clarify, the url tag was specifically created to prevent such
problems. Suppose an entry is changed in the urlconf, it had to be
changed in the templates also. This was against the DRY principle
and so Django came up with the url tag. So when you open the
web/urls.py you'll see that I have used something like this...

...
url(r'^edituser/$', 'edituser', name='edit_user'),
....

The urlpattern has a name called edit_user. So in the templates, I can
use this name to reference the matching URL.

So in the templates, I would just use:

...
<a href="{% url edit_user %}">Edit User</a>
....

This is equivalent to...

...
<a href="/edituser/">Edit User</a>
....

Now someday, you decide to change the urlpattern to something like
below...

url(r'^editdelegate/$', 'edituser', name='edit_user'),

or

url(r'^web/edituser/$', 'edituser', name='edit_user'),

We don't have to make changes to the template because the urlpattern
name is still the same and the url tag will expand correctly.

--
Cheers
Theju

Kenneth Gonsalves

unread,
May 29, 2009, 5:06:36 AM5/29/09
to fosscon...@googlegroups.com

thats fine. Now look at this page:

http://greenchilly.in/talks/

click on a talk and it sends you to:
http://greenchilly.in/web/talkfull/1/
instead of:
http://greenchilly.in/talkfull/1/

they are both the same page, but we need to have the second result.

Thejaswi Puthraya

unread,
May 29, 2009, 12:09:28 PM5/29/09
to fossconf-devel
Hi,

On May 29, 2:06 pm, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> On Thursday 28 May 2009 22:56:40 Thejaswi Puthraya wrote:
[snipped]

> thats fine. Now look at this page:
>
> http://greenchilly.in/talks/
>
> click on a talk and it sends you to:http://greenchilly.in/web/talkfull/1/
> instead of:http://greenchilly.in/talkfull/1/
>
> they are both the same page, but we need to have the second result.

Beats me...I can't reproduce the problem on my machine. Can you please
delete the package, do a clean checkout and see if there's a problem.
Or
if you serve your template files from somewhere else, can you update
that?

Check acumen09ece.com for more details of what i mean. I just
hurriedly set
it up with the media server. Also I don't have PIL installed, so the
only change
I made was to comment out the thumbnail loader in web/talksfull.html.

I am heading out to Bengaluru for the next two days. So will be able
to restart
work on this from Monday.

--
Cheers
Theju

Thejaswi Puthraya

unread,
May 29, 2009, 12:14:28 PM5/29/09
to fossconf-devel


On May 29, 9:09 pm, Thejaswi Puthraya <thejaswi.puthr...@gmail.com>
wrote:
Sorry, I meant hurriedly set it up w/o a media server.

--
Cheers
Theju

Thejaswi Puthraya

unread,
Jun 1, 2009, 6:21:24 AM6/1/09
to fossconf-devel

On May 28, 11:54 am, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
> hi,
>
> @theju. I noticed that you have put in the url tag in the templates. The only
> problem is that previously we had a '/web/' prefix to all the views. Now that
> is not there. For example, postsfull used to be:
>
> /web/postsfull/2/
>
> now it is:
> /postsfull/2/
>
> this should be reflected when using the url tag. Am trying to figure out where
> to make the change - if you can please do it.

Has this been resolved or any update on this? Is this a configuration
issue in Apache
or in the settings.py (URL_PREFIX???).

I see that certain changesets are again reverting back to hardcoding
the
URLs again instead of using the tags.

--
Cheers
Theju

Kenneth Gonsalves

unread,
Jun 2, 2009, 8:02:24 PM6/2/09
to fosscon...@googlegroups.com
On Monday 01 June 2009 15:51:24 Thejaswi Puthraya wrote:
> > this should be reflected when using the url tag. Am trying to figure out
> > where to make the change - if you can please do it.
>
> Has this been resolved or any update on this? Is this a configuration
> issue in Apache
> or in the settings.py (URL_PREFIX???).

will check this - must be the reason


>
> I see that certain changesets are again reverting back to hardcoding
> the
> URLs again instead of using the tags.

sorry about that - was cutting and pasting and forgot to change the url

Reply all
Reply to author
Forward
0 new messages