made_in_india
made_in_india

Reputation: 2279

Django : error in importing the url file of an app

I am newbie in django framework

My project urls.py has the following code

        from django.conf.urls import patterns, include, url
        from django.contrib import admin
        admin.autodiscover()

        urlpatterns = patterns('',
             url(r'^rango/$',include(rango.urls)), #my test appliaction
             url(r'^admin/', include(admin.site.urls)),
        )

I have created an app called rango , that i have imported in the main project url file.

Now it throwing the following error, when I am trying to access url .../rango/ Exception Value: name 'rango' is not defined

I can see that in that python path is not correctly set up.

This is the directory structure of my project

           project/
                   project/__init__.py
                   project/urls.py

                   rango/__init__.py

valuable advice required.

Upvotes: 0

Views: 406

Answers (1)

allcaps
allcaps

Reputation: 11228

url(r'^rango/$',include(rango.urls)),

should read:

url(r'^rango/',include('rango.urls')),

No $ and use quotes 'rango.urls'. Because rango without the quotes is not defined.

Upvotes: 2

Related Questions