NameError name 'lang' is not defined, corresponds to name 'polls' is not defined,

161 views
Skip to first unread message

gintare

unread,
Jul 6, 2014, 3:26:15 AM7/6/14
to django...@googlegroups.com
I am trying to create a project "lang" according Django documentation part 1-4 tutorial.

Folder structure:

Scripts\lang\lang\_init_.py
Scripts\lang\lang\settings.py
Scripts\lang\lang\urls.py

Scripts\lang\langu\_init_.py
Scripts\lang\langu\admin.py
Scripts\lang\langu\models.py
Scripts\lang\langu\urlsu.py
Scripts\lang\langu\views.py

************* Scripts\lang\lang\urls.py
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

from langu import views

urlpatterns = patterns('',              
    url(r'^langu/', include(langu.urlsu)),                   
    url(r'^admin/', include(admin.site.urls)),
)


************* Scripts\lang\langu\urlsu.py
from django.conf.urls import patterns, url

from langu import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index')
)


************* Scripts\lang\lang\settings.py
...
INSTALLED_APPS = (
    'django.contrib.admin',
    'langu',
)
ROOT_URLCONF = 'lang.urls'
....




************* Scripts\lang\langu\views.py
from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the poll index.")


Rodrigo Caicedo

unread,
Jul 8, 2014, 1:54:56 PM7/8/14
to django...@googlegroups.com
In your INSTALLED_APPS part in the configuration file, the registered application is called 'langu', and not 'lang'. If you copied your code, that's your problem.

Tom Evans

unread,
Jul 8, 2014, 2:43:15 PM7/8/14
to django...@googlegroups.com
On Tue, Jul 8, 2014 at 6:54 PM, Rodrigo Caicedo
<rodrigui...@gmail.com> wrote:
> In your INSTALLED_APPS part in the configuration file, the registered
> application is called 'langu', and not 'lang'. If you copied your code,
> that's your problem.

I don't think so, he has a project named "lang" (with "lang.settings")
that has an app named "langu".

>
>
>
> On Sunday, July 6, 2014 2:26:15 AM UTC-5, gintare wrote:
>>
>> I am trying to create a project "lang" according Django documentation part
>> 1-4 tutorial.
>>
>> Folder structure:
>>
>> Scripts\lang\lang\_init_.py
>> Scripts\lang\lang\settings.py
>> Scripts\lang\lang\urls.py
>>
>> Scripts\lang\langu\_init_.py
>> Scripts\lang\langu\admin.py
>> Scripts\lang\langu\models.py
>> Scripts\lang\langu\urlsu.py
>> Scripts\lang\langu\views.py

Where is manage.py? Should be at Scripts\lang\manage.py and have
appropriate contents.

I think "lang" and "langu" are not being picked up as python modules
because Scripts\lang is not being added to sys.path, which is one half
of manage.py's two jobs.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages