Структура проектаMySite\registration - приложение django-registrationMySite\profiles - приложение django-profilesMySite\store\customers\model.py - файл с моделями профиля пользователя (код ниже)MySite\store - каталог основного приложения остальные модели в файде models.py в это каталоге.MySite\settings.py:
AUTH_PROFILE_MODULE='store.customers.Customer'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'store',
'store.customers',
'registration',
'profiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
)
MySite\urls.py все урлы кроме первых двух работают корректно.
urlpatterns = patterns('',
(r'^accounts/', include('registration.backends.default.urls')),
(r'^accounts/profile/', include('profiles.urls')),
(r'^products/$', products),
(r'^product/$', product),
(r'^gallery/$', gallery),
(r'^search/$', search),
(r'^faq/$', faq),
(r'^cart/$', cart),
(r'^dandp/$', main),
(r'^index/$', main),
(r'^$', main),
(r'^static/(?P.)$', 'django.views.static.serve', {'document_root': 'static'}),
)
Модель профайла пользователя:
# -- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
from django.contrib.localflavor.us.models import PhoneNumberField, USStateField
class Customer(models.Model):
'''
Расширяем базовую модель User
Добавляем в неё адресс покупателя и номер его телефона.
'''
user = models.ForeignKey(User)
address = models.ForeignKey('CustomerAddress')
phone_number = models.CharField(max_length=100, blank=True)
class CustomerAddress(models.Model):
'''
Полноценный адресс
'''
city = models.CharField(max_length=100)
street_home = models.CharField(max_length=100)
porch = models.CharField(max_length=100)
apartment = models.CharField(max_length=100)
floor = models.IntegerField(max_length=100)
lift = models.BooleanField()
registration работает нормально. Но после аутентификации происходит переход на /accounts/profile/ и выскакивает исключение
C:\Python27\lib\site-packages\django\core\handlers\base.py in get_response
response = callback(request, callback_args, *callback_kwargs) ...
▶ Local vars
C:\Users\7\Python\MySite\MySite\profiles\views.py in profile_list
profile_model = utils.get_profile_model() ...
▶ Local vars
C:\Users\7\Python\MySite\MySite\profiles\utils.py in get_profile_model
raise SiteProfileNotAvailable
Почитал тут, но так и не понял, что же надо писать в AUTH_PROFILE_MODULE и как по уму надо было делать. Примного буду благодарен за ответ на этот вопрос, а так же за указание на какие-либо другие ошибки.
Updated 19 Sept. 2012, 10:54 by RooshRoosh.