Jump to content
Fórum Script Brasil
  • 0

Problema com Django


marcos_regato
 Share

Question

Boa noite, estou estudando Django, comprei o livro Django Essencial, escrevi o mesmo cógido do livro

import sys

from django.conf import settings

settings.cofigure(
    DEBUG=True,
    SECRET_KEY='thisisthesecretkey',
    ROOT_URLCONF=__name__,
    MIDDLEWARE_CLASSES=(
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ),

from django.conf.urls import url
from django.http import HttpResponse

def index(request):
    return HttpResponse('deu certo')

urlpatterns=(
    url(r'^$',index),

)
if __name__=="__main__":
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

mas deu um erro.

Traceback (most recent call last):
File "settings", line 5, in <module>
settings.cofigure(
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting cofigure, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Alguém pode me ajuda?

Edited by marcos_regato
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...