- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经将用户的创建与函数 create_user_profile 连接起来,当我创建我的用户时出现问题,我似乎连接的函数被调用了两次,而 UserProfile 试图被创建两次,女巫触发了一个错误
列 user_id 不是唯一的
Request Method: POST
Request URL: http://127.0.0.1:8000/register/
Django Version: 1.3
Exception Type: IntegrityError
Exception Value:
column user_id is not unique
Exception Location: c:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 234
Python Executable: c:\Python27\python.exe
Python Version: 2.7.2
[13/Apr/2012 10:20:57] "GET /register/ HTTP/1.1" 200 176691
DEBUG:django.db.backends:(0.002) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."last_name" = favicon ; args=(u'favicon',)
DEBUG:django.db.backends:(0.001) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."last_name" = testuser2 ; args=(u'testuser2',)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."username" LIKE testuser2@gmail.com ESCAPE '\' ; args=(u'testus
er2@gmail.com',)
DEBUG:django.db.backends:(0.001) INSERT INTO "auth_user" ("username", "first_name
", "last_name", "email", "password", "is_staff", "is_active", "is_superuser", "la
st_login", "date_joined") VALUES (testuser2@gmail.com, , , testuser2@gmail.com, s
ha1$9bc1b$c9d377a1bf228ef74eb6931a9ed02d5c455e1576, False, True, False, 2012-04-1
3 10:21:13.949000, 2012-04-13 10:21:13.949000); args=(u'testuser2@gmail.com', '',
'', u'testuser2@gmail.com', 'sha1$9bc1b$c9d377a1bf228ef74eb6931a9ed02d5c455e1576
', False, True, False, u'2012-04-13 10:21:13.949000', u'2012-04-13 10:21:13.94900
0')
====================================
=
DEBUG:django.db.backends:(0.002) INSERT INTO "page_userprofile" ("user_id", "thum
b", "name", "title", "description", "phone", "birthday", "address", "lat", "lng",
"gender", "creation_date", "updation_date") VALUES (13, , , , , , None, , , , ,
2012-04-13 10:21:14.131000, 2012-04-13 10:21:14.131000); args=(13, '', '', '', ''
, '', None, '', '', '', '', u'2012-04-13 10:21:14.131000', u'2012-04-13 10:21:14.
131000')
DEBUG:django.db.backends:(0.002) INSERT INTO "page_pagesettings" ("user_id", "bac
kground_url", "background_repeat", "showAvatar", "showTags", "color_background",
"color_panel_background", "color_panel_background_opacity", "color_name", "color_
title", "color_description", "color_links", "font_name", "font_title", "font_desc
ription", "font_tags_and_links", "font_size_name", "font_size_title", "font_size_
description", "font_size_tags_and_links", "can_contact_via_email", "panel_positio
n") VALUES (13, , 0, False, True, , , , , , , , , , , , , , , , True, ); args=(13
, '', u'0', False, True, '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', True, '')
====================================
=
DEBUG:django.db.backends:(0.002) INSERT INTO "page_userprofile" ("user_id", "thum
b", "name", "title", "description", "phone", "birthday", "address", "lat", "lng",
"gender", "creation_date", "updation_date") VALUES (13, , , , , , None, , , , ,
2012-04-13 10:21:14.442000, 2012-04-13 10:21:14.442000); args=(13, '', '', '', ''
, '', None, '', '', '', '', u'2012-04-13 10:21:14.442000', u'2012-04-13 10:21:14.
442000')
DEBUG:django.db.backends:(0.000) SELECT "page_userprofile"."id", "page_userprofil
e"."user_id", "page_userprofile"."thumb", "page_userprofile"."name", "page_userpr
ofile"."title", "page_userprofile"."description", "page_userprofile"."phone", "pa
ge_userprofile"."birthday", "page_userprofile"."address", "page_userprofile"."lat
", "page_userprofile"."lng", "page_userprofile"."gender", "page_userprofile"."cre
ation_date", "page_userprofile"."updation_date" FROM "page_userprofile" LIMIT 21;
args=()
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 1 ; args=(1,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 2 ; args=(2,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 4 ; args=(4,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 5 ; args=(5,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 7 ; args=(7,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 8 ; args=(8,)
DEBUG:django.db.backends:(0.001) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 9 ; args=(9,)
DEBUG:django.db.backends:(0.001) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 10 ; args=(10,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 11 ; args=(11,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 12 ; args=(12,)
DEBUG:django.db.backends:(0.000) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."id" = 13 ; args=(13,)
[13/Apr/2012 10:21:15] "POST /register/ HTTP/1.1" 500 446959
DEBUG:django.db.backends:(0.001) SELECT "auth_user"."id", "auth_user"."username",
"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_us
er"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_
superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user"
WHERE "auth_user"."last_name" = favicon ; args=(u'favicon',)
def create_user_profile(sender, instance, created, **kwargs):
if created:
print('')
print('')
print('=========================================')
print('')
print('')
UserProfile.objects.create(user=instance)
PageSettings.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
newUser = User.objects.create_user(username, username, password)
newUser.last_name = slug
if(registerAs == 'company'):
newUser.first_name = 'company'
else:
newUser.first_name = 'user'
#newUser.save()
最佳答案
使用 dispatch_uid
参数为您的信号提供唯一标识符。
post_save.connect(create_user_profile, sender=User, dispatch_uid="create_user_profile")
关于用户创建时的 Django 信号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10141045/
所以我目前正在研究 C 中的 POSIX 线程和信号编程。我的讲师使用 sigset(int sigNumber, void* signalHandlerFUnction) 因为他的笔记不是世界上最好
我正在制作一个 C++ 游戏,它要求我将 36 个数字初始化为一个 vector 。你不能用初始化列表初始化一个 vector ,所以我创建了一个 while 循环来更快地初始化它。我想让它把每个数字
我正在尝试让 Python 发送 EOF信号 (Ctrl+D) 通过 Popen() .不幸的是,我找不到任何关于 Popen() 的引用资料。 *nix 类系统上的信号。这里有谁知道如何发送 EOF
我正在尝试让 Python 发送 EOF信号 (Ctrl+D) 通过 Popen() .不幸的是,我找不到任何关于 Popen() 的引用资料。 *nix 类系统上的信号。这里有谁知道如何发送 EOF
我正在学习编码并拥有一个实时的 Django 项目来保持我的动力。在我的 Django 应用程序中,用户留下评论,而其他人则回复所述评论。 每次用户刷新他们的主页时,我都会计算他们是否收到了关于他们之
登录功能中的django信号有什么用?用户已添加到请求 session 表中。那么 Django auth.login 函数中对信号的最后一行调用是什么? @sensitive_post_param
我已经将用户的创建与函数 create_user_profile 连接起来,当我创建我的用户时出现问题,我似乎连接的函数被调用了两次,而 UserProfile 试图被创建两次,女巫触发了一个错误 列
我有一个来自生产者对象处理的硬件的实时数据流。这会连接到一个消费者,该消费者在自己的线程中处理它以保持 gui 响应。 mainwindow::startProcessing(){ QObje
在我的 iPhone 应用程序中,我想提供某种应用程序终止处理程序,该处理程序将在应用程序终止之前执行一些最终工作(删除一些敏感数据)。 我想尽可能多地处理终止情况: 1) 用户终止应用 2) 设备电
我试图了解使用 Angular Signals 的优势。许多解释中都给出了计数示例,但我试图理解的是,与我下面通过变量 myCount 和 myCountDouble 所做的方式相比,以这种方式使用信
我对 dispatch_uid 的用法有疑问为信号。 目前,我通过简单地添加 if not instance.order_reference 来防止信号的多次使用。 .我现在想知道是否dispatch
有时 django 中的信号会被触发两次。在文档中,它说创建(唯一)dispatch_uid 的一个好方法是模块的路径或名称[1] 或任何可哈希对象的 ID[2]。 今天我尝试了这个: import
我有一个用户定义的 shell 项目,我试图在其中实现 cat 命令,但允许用户单击 CTRL-/ 以显示下一个 x 行。我对信号很陌生,所以我认为我在某个地方有一些语法错误...... 主要...
http://codepad.org/rHIKj7Cd (不是全部代码) 我想要完成的任务是, parent 在共享内存中写入一些内容,然后 child 做出相应的 react ,并每五秒写回一些内容
有没有一种方法可以找到 Qt 应用程序中信号/槽连接的总数有人向我推荐 Gamma 射线,但有没有更简单的解决方案? 最佳答案 检查 Qt::UniqueConnection . This is a
我正在实现一个信号/插槽框架,并且到了我希望它是线程安全的地步。我已经从 Boost 邮件列表中获得了很多支持,但由于这与 boost 无关,我将在这里提出我的未决问题。 什么时候信号/槽实现(或任何
在我的代码中,我在循环内创建相同类型的新对象并将信号连接到对象槽。这是我的试用版。 A * a; QList aList; int aCounter = 0; while(aCounter aLis
我知道 UNIX 上的 C 有 signal() 可以在某些操作后调用某些函数。我在 Windows 上需要它。我发现了,它存在什么 from here .但是我不明白如何正确使用它。 我在 UNIX
目前我正在将控制台 C++ 项目移植到 Qt。关于移植,我有一些问题。现在我的项目调整如下我有一个派生自 QWidget 的 Form 类,它使用派生自 QObject 的其他类。 现在请告诉我我是否
在我的 Qt 多线程程序中,我想实现一个基于 QObject 的基类,以便从它派生的每个类都可以使用它的信号和槽(例如抛出错误)。 我实现了 MyQObject : public QObject{..
我是一名优秀的程序员,十分优秀!