Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用django注册创建用户配置文件_Django_Django Registration - Fatal编程技术网

无法使用django注册创建用户配置文件

无法使用django注册创建用户配置文件,django,django-registration,Django,Django Registration,我正在使用django注册应用程序。我正在尝试创建一个社交网站。我是一个网站开发新手。以下是我得到的错误: 环境: 申请方式:邮寄 请求URL:127.0.0.1:8000/帐户/注册/ Django版本:1.4.2 Python版本:2.7.2 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.s

我正在使用django注册应用程序。我正在尝试创建一个社交网站。我是一个网站开发新手。以下是我得到的错误:

环境:

申请方式:邮寄 请求URL:127.0.0.1:8000/帐户/注册/

Django版本:1.4.2 Python版本:2.7.2

Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'registration_defaults',
 'django.contrib.admin',
 'registration',
 'polls')
Installed Middleware:
('django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/registration/views.py" in register
  187.             new_user = backend.register(request, **form.cleaned_data)
File "/Library/Python/2.7/site-packages/registration/backends/default/__init__.py" in register
  79.                                                                     password, site)
File "/Library/Python/2.7/site-packages/django/db/transaction.py" in inner
  209.                 return func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/registration/models.py" in create_inactive_user
  78.         new_user = User.objects.create_user(username, email, password)
File "/Library/Python/2.7/site-packages/django/contrib/auth/models.py" in create_user
  160.         user.save(using=self._db)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save
  463.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save_base
  565.                 created=(not record_exists), raw=raw, using=using)
File "/Library/Python/2.7/site-packages/django/dispatch/dispatcher.py" in send
  172.             response = receiver(signal=self, sender=sender, **named)
File "/Users/dineshsingh/Desktop/django/mysite/users/models.py" in create_user_profile
  20.         UserProfile.objects.create(user=instance)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py" in create
  137.         return self.get_query_set().create(**kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in create
  377.         obj.save(force_insert=True, using=self.db)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save
  463.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save_base
  551.                 result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py" in _insert
  203.         return insert_query(self.model, objs, fields, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in insert_query
  1593.     return query.get_compiler(using=using).execute_sql(return_id)
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  910.             cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py" in execute
  40.             return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  344.             return Database.Cursor.execute(self, query, params)

Exception Type: DatabaseError at /accounts/register/
Exception Value: no such table: users_userprofile
我们将非常感谢您的帮助

According to the Error stack, I think you are doing it in the wrong manner. 
It may be that you are creating an app  named `users` which is not required here. 
下面是如何使用
django注册的分步过程

login.html — user login form
logout.html — shown after a user has logged out
password_change_form.html — password change form
password_change_done.html — shown after successful password change
password_reset_form.html — ask user for email to send password-reset mail to
password_reset_email.html — template for password-reset mail
password_reset_done.html — shown after password-reset email has been sent
password_reset_confirm.html — ask user for new password after reset
password_reset_complete.html — shown after successful password reset
registration_form.html — user registration form
registration_complete.html — shown after a user has registered
activation_email_subject.txt — subject of activation email
activation_email.txt — template for activation email
activate.html — shown after a user has activated his account
安装django注册后,我们需要将其添加到
settings.py
文件中,以确保我们的django引擎读取并加载它

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'registration',     #<--Here I have added
)
现在更新
urls.py
文件,将所有
/accounts/
请求发送到
django注册
应用程序

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    ...
    (r'^accounts/', include('registration.urls')),
    ...
)
现在您需要创建一些模板来支持您的
django注册

login.html — user login form
logout.html — shown after a user has logged out
password_change_form.html — password change form
password_change_done.html — shown after successful password change
password_reset_form.html — ask user for email to send password-reset mail to
password_reset_email.html — template for password-reset mail
password_reset_done.html — shown after password-reset email has been sent
password_reset_confirm.html — ask user for new password after reset
password_reset_complete.html — shown after successful password reset
registration_form.html — user registration form
registration_complete.html — shown after a user has registered
activation_email_subject.txt — subject of activation email
activation_email.txt — template for activation email
activate.html — shown after a user has activated his account
一个基本模型,您需要在这些文件中输入的内容可以是

现在我希望你能让它运行起来

没有更多的链接可以查看。

您的
设置.py中是否有正确的
身份验证配置文件\u模块

这似乎应该是:

    AUTH_PROFILE_MODULE = 'registration.RegistrationProfile'

好的,做一件事,手动检查是否在点击
syncdb
时创建了所有的表。我已经检查了,并且没有创建users\u userprofile表。创建的表列表是:auth_组、auth_组权限、auth_权限、auth_用户、auth_用户组、auth_用户权限、django_管理日志、django_内容类型、django_会话、django_站点、轮询选择、轮询、注册配置文件,不,不会有任何名为
users\u userprofile
的表
registration\u registrationprofile
是这里的主表。非常感谢!我使用的是django注册默认值,它有点搞砸了。我做这件事的方式不对。然而,我遵循了你的devdoodles链接,它工作得很好。很高兴知道它对你有效,现在我把它作为一个答案,这样,如果其他人有这个问题,他们可以参考答案。你可以考虑接受答案为<代码>右<代码>。