interpretting urls

27 views
Skip to first unread message

Smaran Harihar

unread,
Jun 26, 2012, 12:52:06 PM6/26/12
to django...@googlegroups.com
Hi,

I am bit confused about what exactly do these urls imply in the url.py

urlpatterns = patterns('',
 (r'^(?:index/?)?$', 'geonode.views.index'),
    (r'^(?P<page>help)/?$', 'geonode.views.static'),
    (r'^developer/?$', 'geonode.views.developer'),
    url(r'^lang\.js$', 'django.views.generic.simple.direct_to_template',
               {'template': 'lang.js', 'mimetype': 'text/javascript'}, 'lang'),
    (r'^maps/', include('geonode.maps.urls'))


I know that a simple url syntax like this,

url(r'^data/$', 'geonode.maps.views.browse_data')

implies, that it will execute the function browse_data in views.py in the maps directory, inside the geonode dir.

But not sure what the above urls imply. I am absolutely new to Django so can u explain in simple terms.

--
Thanks & Regards
Smaran Harihar

bruno desthuilliers

unread,
Jun 27, 2012, 7:16:11 AM6/27/12
to django...@googlegroups.com


On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
Hi,

I am bit confused about what exactly do these urls imply in the url.py


This is all documented here : https://docs.djangoproject.com/en/dev/topics/http/urls/

Smaran Harihar

unread,
Jun 27, 2012, 5:53:56 PM6/27/12
to django...@googlegroups.com

Going thru the doc link you gave, I did not understand the term middleware request processing?

but if the incoming HttpRequest object has an attribute called urlconf (set by middleware request processing), its value will be used in place of the ROOT_URLCONF setting.



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

Smaran Harihar

unread,
Jun 27, 2012, 6:29:39 PM6/27/12
to django...@googlegroups.com
The doc did not give details for r'^(?:index/?)?$', in

(r'^(?:index/?)?$', 'geonode.views.index')

Thanks,
Smaran

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers <bruno.des...@gmail.com> wrote:

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

Jani Tiainen

unread,
Jun 28, 2012, 3:13:24 AM6/28/12
to django...@googlegroups.com
Hi,

Quote from URL dispatcher documentation:
"To design URLs for an app, you create a Python module informally called
a URLconf (URL configuration). This module is pure Python code and is a
simple mapping between URL patterns (as simple regular expressions) to
Python callback functions (your views).
"

So you need to do your homework and learn how to read and write (Python)
regular expressions since pretty much everything in url
config is a regular expression.

28.6.2012 1:29, Smaran Harihar kirjoitti:
> The doc did not give details for *r'^(?:index/?)?$'*, in
>
> (r'^(?:index/?)?$', 'geonode.views.index')
>
> Thanks,
> Smaran
>
> On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers
> <bruno.des...@gmail.com <mailto:bruno.des...@gmail.com>>

bruno desthuilliers

unread,
Jun 28, 2012, 6:25:56 AM6/28/12
to django...@googlegroups.com
On Wednesday, June 27, 2012 11:53:56 PM UTC+2, Sam007 wrote:

Going thru the doc link you gave, I did not understand the term middleware request processing?

but if the incoming HttpRequest object has an attribute called urlconf (set by middleware request processing), its value will be used in place of the ROOT_URLCONF setting.



It's also in the FineManual. If you look at the doc's home page, you'll find a very explicit reference to middlewares :

https://docs.djangoproject.com/en/dev/#the-view-layer

Should I mention that there's a "search" feature in the doc too ?

kenneth gonsalves

unread,
Jun 28, 2012, 6:50:01 AM6/28/12
to django...@googlegroups.com
On Thu, 2012-06-28 at 03:25 -0700, bruno desthuilliers wrote:
> ROOT_URLCONF<https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ROOT_URLCONF>
> > setting.
> >
> >
> >
> It's also in the FineManual. If you look at the doc's home page,
> you'll
> find a very explicit reference to middlewares :
>
> https://docs.djangoproject.com/en/dev/#the-view-layer
>
> Should I mention that there's a "search" feature in the doc too ?

but that is not yet fixed, it does not do multiword searches - better to
use duckduckgo's site feature.
--
regards
Kenneth Gonsalves

Reply all
Reply to author
Forward
0 new messages