Can't access my django runserver

124 views
Skip to first unread message

Umar Kambala

unread,
Jun 27, 2018, 5:42:05 AM6/27/18
to django...@googlegroups.com

Please after going through my django polls, now if I runserver I gets this error

'APP_DIRS' : True,
SyntaxError: invalid syntax.
Please wat do I do?

Joshua Kayode

unread,
Jun 27, 2018, 8:45:01 AM6/27/18
to django...@googlegroups.com
I think you need to give more details, we are all ready to help! 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPkbFbagk%2B4m5Ze3THLfAABBx8fVENHG7QqunA81pYnnUwXJhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Umar Kambala

unread,
Jun 29, 2018, 5:24:55 AM6/29/18
to django...@googlegroups.com

Thanks for the reply
My problem is when I run python manage.py runserver I gets this error:

'APP_DIRS': True,
SyntaxError: invalid syntax

Am following this tutorial on the django polls section

Mikhailo Keda

unread,
Jun 29, 2018, 9:00:55 AM6/29/18
to Django users
show your code

Umar Kambala

unread,
Jun 30, 2018, 6:22:50 AM6/30/18
to django...@googlegroups.com

this are my codes...

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']
ALLOWED_HOSTS = ['localhost', '.pythonanywhere.com']


# Application definition

INSTALLED_APPS = [
    'polls.apps.PollsConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'mysite.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'GMT'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'STATIC')
MASSAGE_STORAGE = 'django.contrib.message.storage.session.SessionStorage'


this what i get when i run python manage.py runserver
line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 317, in execute
    settings.INSTALLED_APPS
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__
    self._setup(name)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Admin\Desktop\Djan Polls\mysite\mysite\settings.py", line 60
    'APP_DIRS': True,
             ^
SyntaxError: invalid syntax

On Fri, Jun 29, 2018 at 6:00 AM, Mikhailo Keda <mri...@gmail.com> wrote:
show your code

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jason

unread,
Jun 30, 2018, 8:48:30 AM6/30/18
to Django users
you're missing a comma at the end of 

 'DIRS': [os.path.join(BASE_DIR, 'templates')]

for future reference, if you want people to help you, give the information up front as well as context.  Your original posting showed minimal information, so there was nothing we could do until you posted the above.

You should also be using a text editor like atom, sublime, vscode, etc with a graphical linter so you can see syntax errors like the above more easily.

Glen D souza

unread,
Jun 30, 2018, 9:05:22 AM6/30/18
to django...@googlegroups.com
I think there is a ' , ' missing after 'DIRS' in Templates settings
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPkbFbZSz-KFDZ1HdKCAgXCTb-noVmLWPUM-p2ijZxuK0Kjwow%40mail.gmail.com.

Anirudh Jain

unread,
Jun 30, 2018, 9:05:22 AM6/30/18
to django...@googlegroups.com
You forgot to put 'comma' after DIRS': [os.path.join(BASE_DIR, 'templates')] in templates.

It should be DIRS': [os.path.join(BASE_DIR, 'templates')], 

show your code
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Umar Kambala

unread,
Jul 1, 2018, 5:26:49 AM7/1/18
to django...@googlegroups.com

Umar Kambala

unread,
Jul 1, 2018, 5:27:27 AM7/1/18
to django...@googlegroups.com

Am very grateful

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Umar Kambala

unread,
Jul 1, 2018, 5:28:03 AM7/1/18
to django...@googlegroups.com

Am very grateful

show your code
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Ripon Uddin

unread,
Jul 1, 2018, 1:45:14 PM7/1/18
to django...@googlegroups.com
Anybody can help about Django Auth Login please ?


Am very grateful

show your code
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jason

unread,
Jul 1, 2018, 4:11:14 PM7/1/18
to Django users
what does this have to do with the original question of this post?

Umar Kambala

unread,
Jul 1, 2018, 5:49:58 PM7/1/18
to django...@googlegroups.com
please this what i got after correcting my codes

when i run python manage.py runserver 


C:\Users\Admin\Desktop\Djan Polls>cd mysite

C:\Users\Admin\Desktop\Djan Polls\mysite>python manage.py runserver
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 16, in setup
    from django.urls import set_script_prefix
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 8, in <module>
    register = template.Library()
NameError: name 'template' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 340, in execute
    _parser = self.fetch_command('runserver').create_parser('django', 'runserver')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 216, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 10, in <module>
    from django.core.servers.basehttp import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 17, in <module>
    from django.core.wsgi import get_wsgi_application
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\wsgi.py", line 8, in <module>
    from django.core.handlers import base
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 7, in <module>
    from django.urls import get_resolver, set_urlconf
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 8, in <module>
    register = template.Library()
NameError: name 'template' is not defined

C:\Users\Admin\Desktop\Djan Polls\mysite>python manage.py runserver
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 16, in setup
    from django.urls import set_script_prefix
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 11, in <module>
    class PrefixNode(template.Node):
NameError: name 'template' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 340, in execute
    _parser = self.fetch_command('runserver').create_parser('django', 'runserver')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 216, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 10, in <module>
    from django.core.servers.basehttp import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 17, in <module>
    from django.core.wsgi import get_wsgi_application
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\wsgi.py", line 8, in <module>
    from django.core.handlers import base
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 7, in <module>
    from django.urls import get_resolver, set_urlconf
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 11, in <module>
    class PrefixNode(template.Node):
NameError: name 'template' is not defined

C:\Users\Admin\Desktop\Djan Polls\mysite>python manage.py runserver
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 16, in setup
    from django.urls import set_script_prefix
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 8, in <module>
    register = template.Library()
NameError: name 'template' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 340, in execute
    _parser = self.fetch_command('runserver').create_parser('django', 'runserver')
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 216, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 10, in <module>
    from django.core.servers.basehttp import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 17, in <module>
    from django.core.wsgi import get_wsgi_application
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\wsgi.py", line 8, in <module>
    from django.core.handlers import base
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 7, in <module>
    from django.urls import get_resolver, set_urlconf
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\__init__.py", line 1, in <module>
    from .base import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\exceptions.py", line 1, in <module>
    from django.http import Http404
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\__init__.py", line 5, in <module>
    from django.http.response import (
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\expressions.py", line 7, in <module>
    from django.db.models import fields
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\fields\__init__.py", line 11, in <module>
    from django import forms
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\boundfield.py", line 5, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 13, in <module>
    from django.templatetags.static import static
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\templatetags\static.py", line 8, in <module>
    register = template.Library()
NameError: name 'template' is not defined


this are the codes

from urllib.parse import quote, urljoin

from django import templates
from django.apps import apps
from django.utils.encoding import iri_to_uri
from django.utils.html import conditional_escape

register = template.Library()


class PrefixNode(template.Node):

def __repr__(self):
return "<PrefixNode for %r>" % self.name

def __init__(self, varname=None, name=None):
if name is None:
raise template.TemplateSyntaxError(
"Prefix nodes must be given a name to return.")
self.varname = varname
self.name = name

@classmethod
def handle_token(cls, parser, token, name):
"""
Class method to parse prefix node and return a Node.
"""
# token.split_contents() isn't useful here because tags using this method don't accept variable as arguments
tokens = token.contents.split()
if len(tokens) > 1 and tokens[1] != 'as':
raise template.TemplateSyntaxError(
"First argument in '%s' must be 'as'" % tokens[0])
if len(tokens) > 1:
varname = tokens[2]
else:
varname = None
return cls(varname, name)

@classmethod
def handle_simple(cls, name):
try:
from django.conf import settings
except ImportError:
prefix = ''
else:
prefix = iri_to_uri(getattr(settings, name, ''))
return prefix

def render(self, context):
prefix = self.handle_simple(self.name)
if self.varname is None:
return prefix
context[self.varname] = prefix
return ''


@register.tag
def get_static_prefix(parser, token):
"""
Populate a template variable with the static prefix,
``settings.STATIC_URL``.

Usage::

{% get_static_prefix [as varname] %}

Examples::

{% get_static_prefix %}
{% get_static_prefix as static_prefix %}
"""
return PrefixNode.handle_token(parser, token, "STATIC_URL")


@register.tag
def get_media_prefix(parser, token):
"""
Populate a template variable with the media prefix,
``settings.MEDIA_URL``.

Usage::

{% get_media_prefix [as varname] %}

Examples::

{% get_media_prefix %}
{% get_media_prefix as media_prefix %}
"""
return PrefixNode.handle_token(parser, token, "MEDIA_URL")


class StaticNode(template.Node):
def __init__(self, varname=None, path=None):
if path is None:
raise template.TemplateSyntaxError(
"Static template nodes must be given a path to return.")
self.path = path
self.varname = varname

def url(self, context):
path = self.path.resolve(context)
return self.handle_simple(path)

def render(self, context):
url = self.url(context)
if context.autoescape:
url = conditional_escape(url)
if self.varname is None:
return url
context[self.varname] = url
return ''

@classmethod
def handle_simple(cls, path):
if apps.is_installed('django.contrib.staticfiles'):
from django.contrib.staticfiles.storage import staticfiles_storage
return staticfiles_storage.url(path)
else:
return urljoin(PrefixNode.handle_simple("STATIC_URL"), quote(path))

@classmethod
def handle_token(cls, parser, token):
"""
Class method to parse prefix node and return a Node.
"""
bits = token.split_contents()

if len(bits) < 2:
raise template.TemplateSyntaxError(
"'%s' takes at least one argument (path to file)" % bits[0])

path = parser.compile_filter(bits[1])

if len(bits) >= 2 and bits[-2] == 'as':
varname = bits[3]
else:
varname = None

return cls(varname, path)


@register.tag('static')
def do_static(parser, token):
"""
Join the given path with the STATIC_URL setting.

Usage::

{% static path [as varname] %}

Examples::

{% static "myapp/css/base.css" %}
{% static variable_with_path %}
{% static "myapp/css/base.css" as admin_base_css %}
{% static variable_with_path as varname %}
"""
return StaticNode.handle_token(parser, token)


def static(path):
"""
Given a relative path to a static asset, return the absolute path to the
asset.
"""
return StaticNode.handle_simple(path)


Anirudh Jain

unread,
Jul 1, 2018, 6:17:23 PM7/1/18
to Django users
Can you please show your directory structure ? Just take the screenshot of your project tree from code editor and that would be enough.

Umar Kambala

unread,
Jul 1, 2018, 6:24:20 PM7/1/18
to django...@googlegroups.com

Please am new to django n I don't know where to get the problem tree. Need further clarifications

On Jul 1, 2018 10:18 PM, "Anirudh Jain" <anirudha...@gmail.com> wrote:
Can you please show your directory structure ? Just take the screenshot of your project tree from code editor and that would be enough.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jason

unread,
Jul 1, 2018, 6:42:30 PM7/1/18
to Django users
You're importing the wrong thing

from django import templates

should be 

from django import template

no "s" on the latter

Umar Kambala

unread,
Jul 4, 2018, 12:24:29 PM7/4/18
to django...@googlegroups.com

Please I made the correction and am still getting the same error

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages