Skip to content
Advertisement

Tag: django

Saving custom user model with django-allauth

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’ cannot be null”) What is the proper way to store Custom user model? django-allauth: 0.12.0; django: 1.5.1;

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 dyno process or, 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. UniqueConstraint provides more functionality than unique_together. unique_together may be deprecated in the future. Original Answer I

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. the DB query required to generate the ‘list’ isn’t actually performed until the object is evaluated. Somewhat irritatingly,

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 it’s possible to log custom admin actions and if so, how?

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 is the best way

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 copied 72 files over. I have also added the below template tag to my template (index.html) file

Advertisement