NameError: name 'admin' is not defined 解决问题的方法:
2010-06-11 15:10
656 查看
步骤:
1、修改settings.py。在INSTALLED_APPS设置中添加“django.contrib.admin”。
2、运行python manage.py syncdb更新数据库
3、修改urls.py。改为:
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
去掉注释。
在运行时,遇到这种问题:注意空格的问题
1、修改settings.py。在INSTALLED_APPS设置中添加“django.contrib.admin”。
2、运行python manage.py syncdb更新数据库
3、修改urls.py。改为:
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
去掉注释。
在运行时,遇到这种问题:注意空格的问题
Traceback (most recent call last): File "D:\python2.6\lib\site-packages\django\core\servers\basehttp.py", line 279, in run self.result = application(self.environ, self.start_response) File "D:\python2.6\lib\site-packages\django\core\servers\basehttp.py", line 651, in __call__ return self.application(environ, start_response) File "D:\python2.6\lib\site-packages\django\core\handlers\wsgi.py", line 241, in __call__ response = self.get_response(request) File "D:\python2.6\lib\site-packages\django\core\handlers\base.py", line 73, in get_response response = middleware_method(request) File "D:\python2.6\lib\site-packages\django\middleware\common.py", line 56, in process_request if (not _is_valid_path(request.path_info) and File "D:\python2.6\lib\site-packages\django\middleware\common.py", line 142, in _is_valid_path urlresolvers.resolve(path) File "D:\python2.6\lib\site-packages\django\core\urlresolvers.py", line 294, in resolve return get_resolver(urlconf).resolve(path) File "D:\python2.6\lib\site-packages\django\core\urlresolvers.py", line 216, in resolve for pattern in self.url_patterns: File "D:\python2.6\lib\site-packages\django\core\urlresolvers.py", line 245, in _get_url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "D:\python2.6\lib\site-packages\django\core\urlresolvers.py", line 240, in _get_urlconf_module self._urlconf_module = import_module(self.urlconf_name) File "D:\python2.6\lib\site-packages\django\utils\importlib.py", line 35, in import_module __import__(name) File "D:\python2.6\Scripts\newtest\..\newtest\urls.py", line 17, in <module> (r'^admin/', include(admin.site.urls)), NameError: name 'admin' is not defined 解决问题的方法:
在urls.py中添加:from django.contrib import admin
二、增加超级用户
manage.py shell
>>>from django.contrib.auth.create_superuser import createsuperuser
>>>createsuperuser()
以上语句可能不能执行,可以改为执行:>>>python manage.py createsuperuser
进入admin管理页面,想将英文显示中文化:
将settings.py中 LANGUAGE_CODE 由 'en-us' 改为 'zh-cn' , TIME_ZONE 建议改为 'CCT'
相关文章推荐
- Python中NameError: name 'reload' is not defined解决方法
- Python 解决 :NameError: name 'reload' is not defined 问题
- Python 解决 :NameError: name 'reload' is not defined 问题
- Python中NameError: name 'reload' is not defined 解决方法
- 解决tensorflow问题, NameError: name 'float32' is not defined
- Python 解决 :NameError: name 'reload' is not defined 问题
- NLTK使用中NameError: name 'FreqDist' is not defined问题解决
- Python 解决 :NameError: name 'reload' is not defined 问题
- Python 解决 :NameError: name 'reload' is not defined 问题
- NameError: name 'strip' is not defined解决方法
- 关于scrapy NameError: global name 'DmozItem' is not defined的解决方法
- Python中用eval将字符串转换为字典时候出错:NameError: name ‘null’ is not defined的解决方法
- Python 解决 :NameError: name 'reload' is not defined 问题
- NameError: name 'admin' is not defined(彻底解决方案)
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- centos username is not in the sudoers file 问题解决方法
- Android Error:main cannot be resolved or is not a field 问题解决方法
- name 'patterns' is not defined 错误解决方法
- firefox ReferenceError: $ is not defined 问题解决
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法