Skip to content
Advertisement

Tag: django

django, “is not JSON serializable” when using ugettext_lazy?

I have this in my views.py Since I start using this import: from django.utils.translation import ugettext_lazy as _ at this line: message = _(‘This is a test message’) I get this error: Why? What am I doing wrong? Answer You can also create you own JSON encoder that will force __proxy__ to unicode. From https://docs.djangoproject.com/en/1.8/topics/serialization/ So now your code can

Django-queryset join without foreignkey

model.py What I want is to get id_noga where dzienrok=1234. I know that dziens should be but it isn’t and I can’t change that. Normally I would use something like but I don’t know how to join and filter those tables without foreignkey. Answer It’s possible to join two tables by performing a raw sql query. But for this case

Python Django send_mail newlines?

I’m using django send_mail like this: Gmail recieves this. And shows my newlines as one whole paragraph. Why? I would like three lines of text, not one. Answer Try sending your email as HTML instead of plain text. Use EmailMessage().

Django Simple Captcha image size

How can I change captcha image size and text padding in image? I read official docs and havn’t found any of those. Answer I have never used this app, but I’ve found in code something: So if you call captch_image with additional paramater scale, you can change the size. If you use urls for this app like You can change

GeoDjango GEOSException error

Trying to install a GeoDjango on my machine. I’m really new to Python and being brought into a project that has been a very tricky install for the other team members. I installed Python 2.7 and GEOS using brew, and running PSQL 9.2.4 but keep getting this error when I try to get the webserver running: Cant seem to find

Django Queryset Filter Missing Quotes

I have a list and I want to filter my Queryset when any of these items is found in a foreign table’s non-primary key ‘test’. So I write something like this: This returns an empty list. When I look at the SQL query it generated, I get: Whereas what it should have been is this: Without the quotes, SQLite3 believes

i18n_patterns: How come some user are accessing /en-us/ where what I have is /en/

I am using i18n_patterns for my URL and yesterday when I launched the live site I noticed through Google Analytics many people are accessing http://www.example.com/**en-us**/ instead of http://www.example.com/**en**/. I do not have http://www.example.com/**en-us**/ link anywhere on my site. Personally, when I try to access the site through http://www.example.com/ I am redirected to http://www.example.com/**en**/ which is the wanted behaviour. Also when

Advertisement