django-1.6

Django custom form ImportError even though file is in the same directory

ぃ、小莉子 提交于 2019-12-11 14:37:29
问题 I'm working through Effective Django's tutorial series. I'm currently having an issue trying to create a custom form to use in an app. I created the forms.py file as instructed in this part of the tutorial, and made the alterations to my views.py file. My directory structure looks like this: (project root) | ├── address.db ├── addressbook │ ├── __init__.py │ ├── __pycache__ │ ├── settings.py │ ├── static │ ├── urls.py │ └── wsgi.py ├── contacts │ ├── __init__.py │ ├── admin.py │ ├── forms.py

Django allauth session JSON serializable error after login

梦想与她 提交于 2019-12-11 07:51:31
问题 I have installed django-allauth, after that this is my settings.py Django_apps = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) Third_party_apps = ( 'avatar', 'allauth', 'allauth.account', 'allauth.socialaccount', 'bootstrapform', 'allauth.socialaccount.providers

Django Many to Many Inline - how to show fields referenced by through model?

跟風遠走 提交于 2019-12-10 01:58:44
问题 I'm trying to customize and many to many inline in the django Admin, but I'm not able to display the fields of the underlying models. Here's a simplified example. Maybe you can tell me how to reference them? Here are my models: class Clown(models.Model): name = models.CharField(max_length=255) def edit_link(self): return ... class Circus(models.Model): clowns = models.ManyToManyField(Clown, blank=True, through='WorkedAt') name = models.CharField(max_length=255) class WorkedAt(models.Model):

running all tests post django 1.6

久未见 提交于 2019-12-08 16:00:32
问题 In django 1.5 and earlier, running python manage.py test would, by default, run all tests in a project (including all those in django.contrib). Subsequent to version 1.6, the default behaviour is to run all the tests in the current directory. What is the best way (v 1.6) to run all tests, either with or without the django.contrib tests? 回答1: Django 1.6 changed the default test runner to: TEST_RUNNER = 'django.test.runner.DiscoverRunner' You can get the old behaviour back by adding to your

How to add a line number to each row of a tabularinline block

不问归期 提交于 2019-12-08 06:40:26
问题 I have a ModelAdmin class with an inline of type TabularInline. What I would like is for each row of the TabularInline to have a line number displayed to the left of it. This number would increment as new records are added to the inline, and would be displayed when the form is being edited. I prefer the line number not be a part of the model for the inlined data, but rather be generated each time a new record is added to or displayed by the inline block. I don't need to keep this number in

Django custom 500 error template not displaying request.user

流过昼夜 提交于 2019-12-07 06:07:17
问题 I'm implementing custom 404 and 500 templates, but while the 404.html template seems to return request.user.is_authenticated fine, the 500.html template fails to return anything. I also checked for request.user and it's just blank on the 500 page. This is very strange, because when I trigger the 500 error, I receive the expected error report e-mail, and it clearly has USER properly defined in the request breakdown. Here's the code I'm using in views.py: def handler404(request): response =

Longer username in Django 1.7

孤街醉人 提交于 2019-12-05 10:17:58
I want to increase the length of the username in django from 30 to around 80, I know it may be duplicate question but the previous answers are not working, for example https://kfalck.net/2010/12/30/longer-usernames-for-django this is for Django 1.2. Did anyone try similar hack for Django>1.5 Thanks in advance In Django 1.5 and above, the recommended approach would be to create a custom user model . Then you can make the username field exactly as you want. I had the same problem few days ago. Finally, I ended just with cutting off first 30 characters of the (old) username (into the new database

Django Many to Many Inline - how to show fields referenced by through model?

纵饮孤独 提交于 2019-12-05 02:00:32
I'm trying to customize and many to many inline in the django Admin, but I'm not able to display the fields of the underlying models. Here's a simplified example. Maybe you can tell me how to reference them? Here are my models: class Clown(models.Model): name = models.CharField(max_length=255) def edit_link(self): return ... class Circus(models.Model): clowns = models.ManyToManyField(Clown, blank=True, through='WorkedAt') name = models.CharField(max_length=255) class WorkedAt(models.Model): clown = models.ForeignKey(Clown) circus = models.ForeignKey(Circus) and my admin: class ClownInline

django-allauth: custom user generates IntegrityError at /accounts/signup/ (custom fields are nulled or lost)

陌路散爱 提交于 2019-12-03 20:15:02
问题 I'm trying to integrate django-allauth with a custom user model (subclassed AbstractUser, but when I test the signup form I get an integrity error due to field (date_of_birth) being null, but the value submitted was u'1976-4-6' I'm learning the new custom user stuff, as well as class-based views as I'm learning django-allauth, so I'm confident that I'm doing something wrong, but after a couple days of reading the github issues, the few tutorials, readthedocs, and stackoverflow questions I

Why is “django.core.context_processors.request” not enabled by default?

瘦欲@ 提交于 2019-12-03 15:57:54
I was troubleshooting a problem with obtaining the request obj with a new project and realized "django.core.context_processors.request" was commented in vanilla installs of Django. Like the title suggests, why would this seemingly helpful context processor be turned off by default? Is it an issue with performance? Is it an issue with security? Is it somehow redundant? Some mild searching has not turned up anything for me, but I thought I'd ask here. This is a good question. The docs say Note that this processor is not enabled by default; you’ll have to activate it. but no explanation. My take