Get name from request.path

2 views
Skip to first unread message

kelvan.ma...@gmail.com

unread,
Dec 25, 2009, 3:10:44 PM12/25/09
to django...@googlegroups.com
Hi,

I'm trying to get the url name of the request.path, resolve only shows if the url exists.
Is there a function that returns the name of the urlpath?

happy holidays,
florian
signature.asc

Shawn Milochik

unread,
Dec 25, 2009, 3:24:33 PM12/25/09
to django...@googlegroups.com
Try this:

request.META['HTTP_HOST']

If not, check the docs for the request object:

http://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects

Shawn

kelvan.ma...@gmail.com

unread,
Dec 25, 2009, 3:45:16 PM12/25/09
to django...@googlegroups.com
request.META['HTTP_HOST'] just return the webadress from the server, I need the name I gave an url un urls.py.
Like reverse just the other way

florian

2009/12/25 Shawn Milochik <sh...@milochik.com>

--

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



signature.asc

Daniel Roseman

unread,
Dec 25, 2009, 4:03:14 PM12/25/09
to Django users
On Dec 25, 8:45 pm, kelvan.mailingl...@gmail.com wrote:
> request.META['HTTP_HOST'] just return the webadress from the server, I need the name I gave an url un urls.py.
> Like reverse just the other way
>
> florian

I'd be interested to know why you need this. The url name is just a
label, it shouldn't have any actual significance. Where are you using
it?
--
DR.

kelvan.ma...@gmail.com

unread,
Dec 28, 2009, 12:06:47 PM12/28/09
to django...@googlegroups.com
I've the site_name with link to the required permission in the db to show only menu entries the user is allowed to see.
It's ugly but I couldn't find a nicer way. The menus can have a parent if it's a submenu, so I need to know the actual mainmenu to load the submenus. If you know a nice way to handle this permission stuff I'd be happy.

2009/12/25 Daniel Roseman <dan...@roseman.org.uk>
signature.asc

Anton Bessonov

unread,
Dec 30, 2009, 9:57:31 AM12/30/09
to django...@googlegroups.com
django.core.urlresolvers.resolve?


kelvan.ma...@gmail.com schrieb:


> request.META['HTTP_HOST'] just return the webadress from the server, I
> need the name I gave an url un urls.py.
> Like reverse just the other way
>
> florian
>
> 2009/12/25 Shawn Milochik <sh...@milochik.com>
>
> Try this:
>
> request.META['HTTP_HOST']
>
> If not, check the docs for the request object:
>
> http://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects
> <http://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects>
>
> Shawn
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com

> <mailto:django...@googlegroups.com>.


> To unsubscribe from this group, send email to

> django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en

> <http://groups.google.com/group/django-users?hl=en>.
>
>
>

Tim

unread,
Dec 30, 2009, 10:28:48 AM12/30/09
to Django users
Perhaps the Sites framework might help achieve this in a more Django-
like way.

http://docs.djangoproject.com/en/1.1/ref/contrib/sites/

Not sure if you've looked into it before and ruled it out... not
entirely sure what you're trying to accomplish.

On Dec 28, 12:06 pm, kelvan.mailingl...@gmail.com wrote:
> I've the site_name with link to the required permission in the db to show only menu entries the user is allowed to see.
> It's ugly but I couldn't find a nicer way. The menus can have a parent if it's a submenu, so I need to know the actual mainmenu to load the submenus. If you know a nice way to handle this permission stuff I'd be happy.
>

> 2009/12/25 Daniel Roseman &lt;dan...@roseman.org.uk&gt;
> On Dec 25, 8:45&nbsp;pm, kelvan.mailingl...@gmail.com wrote:
> &gt; request.META['HTTP_HOST'] just return the webadress from the server, I need the name I gave an url un urls.py.
> &gt; Like reverse just the other way
> &gt;
> &gt; florian


>
> I'd be interested to know why you need this. The url name is just a
> label, it shouldn't have any actual significance. Where are you using
> it?
> --
> DR.
>

>  signature.asc
> < 1KViewDownload

Reply all
Reply to author
Forward
0 new messages