码迷,mamicode.com
首页 > 其他好文 > 详细

Django

时间:2016-10-30 19:37:12      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:could not   admin   round   result   single   define   信息   views   doc   

Last Update : 10/30/2016 16时48分

 

Django Project

Django documentation contents?

 

API Reference?

 

 

Built-in class-based views API?

Class-based views API reference. For introductory material, see the Class-based views topic guide.

 

Forms?

Detailed form API reference. For introductory material, see the Working with forms topic guide.

 

Working with forms?

 

Github

https://github.com/django/django/blob/master/django/forms/forms.py

 

 

Django

 

Startproject

Startapp

Configuration

url & view

template

http://www.douban.com/group/topic/42158933/

https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/

https://github.com/disqus/django-mailviews/commit/31d6832128a591607796cfee32a30ce58919ca01#diff-1

 

Custom template tags and filters

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags

 

south & db

 

 

CRSF

https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

 

static

https://docs.djangoproject.com/en/1.2/howto/static-files/

 

File Upload

https://docs.djangoproject.com/en/1.2/topics/http/file-uploads/

http://www.douban.com/group/topic/21131470/

 

plugin

ckeditor / kindeditor

http://blog.mondlab.com/python/django-ckeditor

http://2goo.info/blog/panjj/Django/2010/11/15/139

http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1836380

 

 

 

 

常见问题

ImproperlyConfigured: Middleware module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" class

 

运行python manage.py runserver时出现下面错误

Traceback (most recent call last):

  File "D:\Python27\lib\wsgiref\handlers.py", line 85, in run

    self.result = application(self.environ, self.start_response)

  File "D:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 72, in __call__

    return self.application(environ, start_response)

  File "D:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 236, in __call__

    self.load_middleware()

  File "D:\Python27\lib\site-packages\django\core\handlers\base.py", line 57, in load_middleware

    raise exceptions.ImproperlyConfigured(‘Middleware module "%s" does not define a "%s" class‘ % (mw_module, mw_classname))

ImproperlyConfigured: Middleware module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" class

SessionAuthenticationMiddleware 这个是1.7里新加的,把 django版本升级就可以解决这个问题

 

如何查看 django版本?

import django

django.VERSION

 

还有一个方法是在 settings.py里删除SessionAuthenticationMiddleware

MIDDLEWARE_CLASSES = (

    ‘django.contrib.sessions.middleware.SessionMiddleware‘,

    ‘django.middleware.common.CommonMiddleware‘,

    ‘django.middleware.csrf.CsrfViewMiddleware‘,

    ‘django.contrib.auth.middleware.AuthenticationMiddleware‘,

    ‘django.contrib.auth.middleware.SessionAuthenticationMiddleware‘ ,

    ‘django.contrib.messages.middleware.MessageMiddleware‘,

    ‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,

    ‘django.middleware.security.SecurityMiddleware‘,

)

 

SNIMissingWarning & InsecurePlatformWarning

D:\virtualenv\lwc-ws>pip install django==1.8

Collecting django==1.8

C:\Python27\lib\site-packages\pip-8.1.1-py2.7.egg\pip\_vendor\requests\packages

urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but

the SNI (Subject Name Indication) extension to TLS is not available on this pla

tform. This may cause the server to present an incorrect TLS certificate, which

can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.

  SNIMissingWarning
C:\Python27\lib\site-packages\pip-8.1.1-py2.7.egg\pip\_vendor\requests\packages

urllib3\util\ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is n

ot available. This prevents urllib3 from configuring SSL appropriately and may c

ause certain SSL connections to fail. For more information, see https://urllib3.

readthedocs.org/en/latest/security.html#insecureplatformwarning.

  InsecurePlatformWarning

 

解决方法:

在cmd中输入:

pip install pyopenssl ndg-httpsclient pyasn1

 

上次生效版本:

pyOpenSSL==16.0.0

pyasn1==0.1.9

ndg-httpsclient==0.4.2

 

 

Could not find a version that satisfies the requirement djangocms-installer (from versions: )

No matching distribution found for djangocms-installer

 

使用-vvv打开debug信息

(django-cms) D:\virtualenv\django-cms>pip install djangocms-installer –vvv

 

Collecting djangocms-installer

  1 location(s) to search for versions of djangocms-installer:

  * https://pypi.python.org/simple/djangocms-installer/

  Getting page https://pypi.python.org/simple/djangocms-installer/

  Looking up "https://pypi.python.org/simple/djangocms-installer/" in the cache

  No cache entry available

  Starting new HTTPS connection (1): pypi.python.org

最后发现是fiddler开了的原因,关了就好了

 

django.core.exceptions.ImproperlyConfigured: LANGUAGE_CODE "zh-cn" must have a matching entry in LANGUAGES

https://docs.djangoproject.com/en/1.8/ref/settings/

 

Syncdb 1406 data too long for column ‘name‘

Verbose name can be too long

 

ImproperlyConfigured : There are duplicate field(s) in RailPackageAdmin.fieldsets

Fieldset sequence in admin should align with model definition

 

RegistrationForm‘ object has no attribute ‘clean_data

关于Django中出现上述问题的解决方法

code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Newfo...Karen

上述网址第八条

Django语法更新

Newforms:clean_data------>cleaned_data

 

[u‘ManagementForm data is missing or has been tampered with‘]

Need prefix for formset

 

TemplateDoesNotExist

TEMPLATE_DIRS = (

‘simpleToDo/simpleToDo/templates‘

)

simpleToDo: folder

simpleToDo: package name

templates: html folder

 

Windows用户必须使用斜杠而不是反斜杠。 get_template() 假定的是 Unix 风格的文件名符号约定。

 

‘url‘ requires a non-empty first argument. . The syntax changed in Django 1.5, see the docs.

 

从django1.5 开始

{% url blog_content blog_id=id %}"

需要修改为:

{% url ‘blog_content‘ blog_id=id %}"

 

no such table auth user

‘NAME‘: ‘db.sqlite3‘

修改为

‘NAME‘: os.path.join(BASE_DIR,‘db.sqlite3‘)

 

No module named django.core

 

初步原因是装了多个版本的Python导致的。

解决方法之一就是直到dianjo安装目录所在的Python来执行这个命令。如:

python c:\python27\scripts\django-admin.py startproject mysite

以及

C:\Python27\python.exe manage.py runserver

这个问题就会解决了。

 

 

 

Django

标签:could not   admin   round   result   single   define   信息   views   doc   

原文地址:http://www.cnblogs.com/2dogslife/p/6013436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!