django 1.10.3 userena使用
6055 ワード
参照 http://docs.django-userena.org/en/latest/installation.html#required-settings
http://wzgdavid.iteye.com/blog/2310816
1、
import django
django.VERION
djangoバージョンは1.10.3であることがわかった.
2、
実行python manage.py startap accounts、問題が発生しました.cannot import name patterns.
3、
ヒントによって、site-packages\gurardian\computを開きます.
from django.co nf.urls import urlを削除します.patterns、include、handle 404、handle 500の中のpatterns.
4、
pythonを再実行 manage.py startap accounts、問題解決.
5、
migrateとmakemigrations
6、
もし会ったら登録できますが、提出したらserver error 500になります.
portを465または587に変更する.
7、
server error 500はエラーが多いので、debug=Trueを設定してください.
参考文:
使っているのはdjango 1.97で、userena 2.0.1です.
元々の文書の順番が出ませんでしたが、私が走り出す順番は?
1
pip install django-userena
2
Required settings
You need to make some changes Django settings if you want to use Userena in your project.This means modifying
Begin by adding ,
次のadd
3
Start New App
Next,you need to create a new ap on your Django project.In your Command Protot shell,type:
次のテキスト、add
4
accounts.modelsに加入する
Pythonコード
from __future_. import unicode_literals from django.db import models from django.com ntrib.auth.models import User from django.utils.translation import uettext as _ from userena.models import Userena BaseProfile クラス MyProfile: user = models.OneToOneField(User、 unique=True、 バーボンセット=('user') relatedmune='myuplofile' favourite_snack = models.chard Field(u(favourite) snack) max length=5)
6 次にurl配置
urls.pyに加入する
Pythonコード
url(r'^accounts/') include('userena.urls')
7 emailの配置がよくて、smatpは自分で配置に行きます.私はqqメールを使います.
Pythonコード
EMAILUSE_TLS = True EMAILHOST = 'smatp.q.com EMAILPORT = 25 EMAILHOST_US ER = '[email protected]' EMAILHOST_PASSWORD = 'hzppuevkhrqubdcd DEFAULT_FROMEMAIL = EMAILHOST_US ER SITE_ID = 1
8
http://wzgdavid.iteye.com/blog/2310816
1、
import django
django.VERION
djangoバージョンは1.10.3であることがわかった.
2、
実行python manage.py startap accounts、問題が発生しました.cannot import name patterns.
3、
ヒントによって、site-packages\gurardian\computを開きます.
from django.co nf.urls import urlを削除します.patterns、include、handle 404、handle 500の中のpatterns.
4、
pythonを再実行 manage.py startap accounts、問題解決.
5、
python manage.py check_permissions migrate makemigrations
はaccount_に出会います.myprofile doesn't existの場合、modelのclass名MyProfileを小文字にして再実行します.migrateとmakemigrations
6、
もし会ったら登録できますが、提出したらserver error 500になります.
portを465または587に変更する.
7、
server error 500はエラーが多いので、debug=Trueを設定してください.
参考文:
使っているのはdjango 1.97で、userena 2.0.1です.
元々の文書の順番が出ませんでしたが、私が走り出す順番は?
1
pip install django-userena
2
Required settings
You need to make some changes Django settings if you want to use Userena in your project.This means modifying
AUTHENTICATION_BACKENDS
、 INSTALLED_APPS
and optionally MIDDLEWARE_CLASSES
.Begin by adding ,
guardian
and easy_thumbnails
to the INSTALLED_APPS
in your settings.py file of your project. django.contrib.sites
must also be present if it is not already(see) Django docs.).次のadd
UserenaAuthenticationBackend
and ObjectPermissionBackend
also in your settings.py file,from django-gardian,at the top of AUTHENTICATION_BACKENDS
.If you only have Django's default backend、adding django-gardian and that of userena will get the follwing:AUTHENTICATION_BACKENDS = (
'userena.backends.UserenaAuthenticationBackend',
'guardian.backends.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend',
)
add the follwing into your settings.py file:ANONYMOUS_USER_ID = -1
3
Start New App
Next,you need to create a new ap on your Django project.In your Command Protot shell,type:
python manage.py startapp accounts
.We are creating a new ap for Userena titled‘accounts’.次のテキスト、add
accounts
userena
to the INSTALLED_APPS
in your settings.py file.4
AUTH_PROFILE_MODULE = 'accounts.MyProfile'
To integrate Django with userena you shound alter the follwing three settings to reflect the URI You have chenn for userena.For example,if userena lives under accounts
:USERENA_SIGNIN_REDIRECT_URL = '/accounts/%(username)s/'
LOGIN_URL = '/accounts/signin/'
LOGOUT_URL = '/accounts/signout/'
5 accounts.modelsに加入する
Pythonコード
from __future_. import unicode_literals from django.db import models from django.com ntrib.auth.models import User from django.utils.translation import uettext as _ from userena.models import Userena BaseProfile クラス MyProfile: user = models.OneToOneField(User、 unique=True、 バーボンセット=('user') relatedmune='myuplofile' favourite_snack = models.chard Field(u(favourite) snack) max length=5)
6 次にurl配置
urls.pyに加入する
Pythonコード
url(r'^accounts/') include('userena.urls')
7 emailの配置がよくて、smatpは自分で配置に行きます.私はqqメールを使います.
Pythonコード
EMAILUSE_TLS = True EMAILHOST = 'smatp.q.com EMAILPORT = 25 EMAILHOST_US ER = '[email protected]' EMAILHOST_PASSWORD = 'hzppuevkhrqubdcd DEFAULT_FROMEMAIL = EMAILHOST_US ER SITE_ID = 1
8
python manage.py check_permissions