How to combine multiple querysets in Django?

Concatenating the querysets into a list is the simplest approach. If the database will be hit for all querysets anyway (e.g. because the result needs to be sorted), this won’t add further cost. from itertools import chain result_list = list(chain(page_list, article_list, post_list)) Using itertools.chain is faster than looping each list and appending elements one by … Read more

django – getlist()

jQuery POST’s arrays with the [] suffix because PHP and some web frameworks understand that convention, and re-build the array on the server-side for you automatically. Django doesn’t work that way, but you should be able to access the data via: ukeys = request.POST.getlist(‘ukeys[]’)

Heroku fails to install pywin32 library

From its README: This is the readme for the Python for Win32 (pywin32) extensions, which provides access to many of the Windows APIs from Python. Heroku doesn’t run on Windows, so there are no Windows APIs available. As a result pywin32 can’t be installed. You either have to host your application on Windows or remove … Read more

Heroku app database resetting

As stated by @DanielRoseman you should not use SQLite on heroku, because SQLite runs in memory, and backs up its data store in files on disk. Let me quote from the heroku doku: SQLite runs in memory, and backs up its data store in files on disk. While this strategy works well for development, Heroku’s … Read more

AngularJS + Django Rest Framework + CORS ( CSRF Cookie not showing up in client )

AngularJS Single Page Web Application on Sub-domain A, talking to a Django JSON (REST) API on Sub-domain B using CORS and CSRF protection Since I’m currently working on a similar setup and was battling to get CORS to work properly in combination with CSRF protection, I wanted to share my own learnings here. Setup – … Read more