I have django custom user model MyUser with one extra field: I also have according to these instructions custom all-auth Signup form class: After submitting SignupForm (field for property MyUser.age is rendered corectly), I get this error: IntegrityError at /accounts/signup/ (1048, “Column ‘age…
Tag: django
Django: ValueError: Cannot create form field because its related model has not been loaded yet
I’m having some trouble with a Django project I’m working on. I now have two applications, which require a fair bit of overlap. I’ve really only started the second project (called workflow) and I’m trying to make my first form for that application. My first application is called po. In…
Django + Heroku: Out of Memory problems
So this is my first time deploying a django instance on Heroku. My site has had 1000 visits so far and 600 unique visits. We get about 60-200 visits per day. The link is https://socialspark.spuro.org/ Today, 6 days into being live – our site is running into a lot of memory issues. I.E., cannot allocate …
How can I set two primary key fields for my models in Django?
I have a model like this: How can I have the primary key be the combination of migration and host? Answer Update Django 4.0 Django 4.0 documentation recommends using UniqueConstraint with the constraints option instead of unique_together. Use UniqueConstraint with the constraints option instead. UniqueConstra…
is not JSON serializable
I have the following ListView But I get following error: Any ideas ? Answer It’s worth noting that the QuerySet.values_list() method doesn’t actually return a list, but an object of type django.db.models.query.ValuesListQuerySet, in order to maintain Django’s goal of lazy evaluation, i.e. th…
Django forms.DateInput does not apply the attributes given in attrs field
Placeholder, class not getting set when tried to apply through the django’s attrs specifier for forms.DateInput The form is a ModelForm. And according to the docs Takes same arguments as TextInput, with one more optional argument: Here is the code : The same is applied for a forms.TextInput and it works…
Django – Custom Admin Actions Logging
All changes you do in Django Admin is logged in the table django_admin_table and you can also see your most recent changes in “Recent Actions”. But when you write own “Admin Actions” and make changes through them nothing is being logged by default. Example: My question is now if itR…
MySQLdb install error – _mysql.c:44:23: error: my_config.h: No such file or directory
I’m trying to install MySQLdb extension, but I get this error any idea what may be the cause? Could be something with permissions? I’m using Mac OX Lion…. This is a part of the error a got. Django is installed fine, but I need to install this extension. Thanks for any help. Answer usually wh…
Filter an evaluated QuerySet in Django
The requirement is for me to be able to access members of an evaluated QuerySet by a string attribute, in this case name. I don’t like the idea of looping over a QuerySet as it seems like there is a more efficient way. After I’ve called something like: And I evaluate it with something like: What i…
Django – referencing static files in templates
I’m having difficulty referencing static files in my templates. I am using Twitter Bootstrap and have the bootstrap files (css, img, js) sitting at mysite/static. I have set the STATIC_URL, STATIC_ROOT and TEMPLATE_CONTEXT_PROCESSORS according to this tutorial. I have run ./manage.py collectstatic which…