On 15 déc, 16:05, josch <joschw...@web.de> wrote:
> Hallo,
>
> I don`t know what is wrong with my code, but I can not call a view in
> the urls.py of my site:
>
> I have an application hspoints. In the folder is a views.py. In will
> post a view files:
>
> urls.py of my Site:
>
> from django.conf.urls.defaults import *
>
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^hspoints/$', include(hspoints.views.index)),

include() is meant to include an app's urls.py module, not to map a
pattern to a view.

>     (r'^admin/', include(admin.site.urls)),
> )
>
> When i start the testserver withhttp://127.0.0.1:8000/hspoints/I
> get:
>
> NameError at /hspoints/
>
> name 'hspoints' is not defined

Indeed.

> When I add import hspoints to the urls.py of my site, what I did not
> have to do in the poll tutorial

Re-read the tutorial more carefully... and then the FineManual's
section about views and urls ;)


The common idiom is to have app-specific urls defined in the app's
urls.py module, then include this urls.py module from the project's
root urls.py, ie:

# hspoints/urls.py

from django.conf.urls.defaults import *
import views

urlpatterns = patterns('',
     (r'^/$', views.index),
     # your other app-specific url patterns here
   )


# urls.py

urlpatterns = patterns('',
     (r'^hspoints/$', include("hspoints.urls")),
     (r'^admin/', include(admin.site.urls)),
 )


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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