Why do I get sqlite error, “unable to open database file”?

Aha, just stumbled across an article explaining this. Also Django have info on their NewbieMistakes page. The solution is to make sure the directory containing the database file also has write access allowed to the process. In my case, running this command fixed the problem: sudo chown www-data .

ow to ‘bulk update’ with Django?

Update: Django 2.2 version now has a bulk_update. Old answer: Refer to the following django documentation section Updating multiple objects at once In short you should be able to use: You can also use F objects to do things like incrementing rows: See the documentation. However, note that: This won’t use ModelClass.save method (so if you have some logic inside it … Read more

Getting stuck at Django error: No module named registration

I installed the registration module, added it to settings.py. When I tried to run syncdb (% python sitename/manage.py syncdb –settings sitename.devsettings) It gave me “Error: No module named registration” The same setup works (using the same files for everything) fine on the server. This happens on my local machine running OS X. I checked the … Read more

Output Django queryset as JSON

I want to serialize my queryset, and I want it in a format as this view outputs: I simply don’t know how to output the queryset instead of the manual data in the example. I’ve tried and but it wont work. What am I doing wrong? Do I need to make a custom JSON Encoder?

How to revert the last migration?

You can revert by migrating to the previous migration. For example, if your last two migrations are: 0010_previous_migration 0011_migration_to_revert Then you would do: You don’t actually need to use the full migration name, the number is enough, i.e. You can then delete migration 0011_migration_to_revert. If you’re using Django 1.8+, you can show the names of all the … Read more

Cannot find command ‘git’ – windows

Download and Install git in your windows from here: Then add its installation bin path to your windows’s environment path. Then you will find the git command at the command prompt globally. This may solve you problem. How to change environment variables : Git: Installing Git in PATH with GitHub client for Windows For Visual … Read more

What is the use of PYTHONUNBUFFERED in docker file?

Setting PYTHONUNBUFFERED to a non empty value ensures that the python output is sent straight to terminal (e.g. your container log) without being first buffered and that you can see the output of your application (e.g. django logs) in real time. This also ensures that no partial output is held in a buffer somewhere and never written … Read more

What is a NoReverseMatch error, and how do I fix it?

The NoReverseMatch error is saying that Django cannot find a matching url pattern for the url you’ve provided in any of your installed app’s urls. The NoReverseMatch exception is raised by django.core.urlresolvers when a matching URL in your URLconf cannot be identified based on the parameters supplied. To start debugging it, you need to start … Read more