django-1.5

Integrity error on django_admin_log after updating existing site to new Django 1.5 user model

喜欢而已 提交于 2019-11-27 13:46:29
问题 Apparently after adding my new user table to the site, django_admin_log still has a FK to auth_user table. Any way to address this? I didn't see this problem in staging or locally so something odd must have taken place. Traceback (most recent call last) : File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1

Django: Can class-based views accept two forms at a time?

陌路散爱 提交于 2019-11-27 06:25:44
If I have two forms: class ContactForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) class SocialForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) and wanted to use a class based view, and send both forms to the template, is that even possible? class TestView(FormView): template_name = 'contact.html' form_class = ContactForm It seems the FormView can only accept one form at a time. In function based view though I can easily send two forms to my template and retrieve the content of both within the request.POST

Migrating existing auth.User data to new Django 1.5 custom user model?

我的未来我决定 提交于 2019-11-27 06:11:32
I'd prefer not to destroy all the users on my site. But I want to take advantage of Django 1.5's custom pluggable user model. Here's my new user model: class SiteUser(AbstractUser): site = models.ForeignKey(Site, null=True) Everything works with my new model on a new install (I've got other code, along with a good reason for doing this--all of which are irrelevant here). But if I put this on my live site and syncdb & migrate, I'll lose all my users or at least they'll be in a different, orphaned table than the new table created for my new model. I'm familiar with South, but based on this post

Implementing multiple user types with Django 1.5

雨燕双飞 提交于 2019-11-27 05:03:40
问题 What is the recommended way to implement multiple user types using Django 1.5's new configurable user model functionality? I would like to have two user types: private users and trade users, each with their own set of required fields. There are two ways I can think to implement this: 1) Multi-table inheritance class BaseUser(AbstractBaseUser): email = models.EmailField(max_length=254, unique=True) # ... class PrivateUser(BaseUser): first_name = models.CharField(max_length=30) last_name =

select_related with reverse foreign keys

醉酒当歌 提交于 2019-11-27 01:15:37
问题 I have two Models in Django. The first has the hierarchy of what job functions (positions) report to which other positions, and the second is people and what job function they hold. class PositionHierarchy(model.Model): pcn = models.CharField(max_length=50) title = models.CharField(max_length=100) level = models.CharField(max_length=25) report_to = models.ForeignKey('PositionHierachy', null=True) class Person(model.Model): first_name = models.CharField(max_length=50) last_name = models

Django: Can class-based views accept two forms at a time?

六月ゝ 毕业季﹏ 提交于 2019-11-26 12:54:06
问题 If I have two forms: class ContactForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) class SocialForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) and wanted to use a class based view, and send both forms to the template, is that even possible? class TestView(FormView): template_name = \'contact.html\' form_class = ContactForm It seems the FormView can only accept one form at a time. In function based view

Migrating existing auth.User data to new Django 1.5 custom user model?

喜你入骨 提交于 2019-11-26 11:56:08
问题 I\'d prefer not to destroy all the users on my site. But I want to take advantage of Django 1.5\'s custom pluggable user model. Here\'s my new user model: class SiteUser(AbstractUser): site = models.ForeignKey(Site, null=True) Everything works with my new model on a new install (I\'ve got other code, along with a good reason for doing this--all of which are irrelevant here). But if I put this on my live site and syncdb & migrate, I\'ll lose all my users or at least they\'ll be in a different,

Setting DEBUG = False causes 500 Error

霸气de小男生 提交于 2019-11-26 03:27:23
问题 Once I change the DEBUG = False , my site will generate 500 (using wsgi & manage.py runserver), and there is no error info in Apache error log and it will run normally when I change debug to True . I\'m using Django 1.5 & Python 2.7.3 here is Apache access log and without any log in apache error log www.beta800.net:80 222.247.56.11 - - [28/Feb/2013:13:42:28 +0800] \"GET / HTTP/1.1\" 500 257 \"-\" \"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97