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 .

Why do I need nginx when I have uWSGI

You don’t. That’s the simple answer, anyway — you don’t need it. uWSGI is itself a capable server. However, other servers like nginx have been around longer and are (probably, anyway) more secure, as well as having additional features not supported by uWSGI — for example, improved handling of static resources (via any combination of …

Read more

Why do I need Nginx and something like Gunicorn?

Overly simplified: You need something that executes Python but Python isn’t the best at handling all types of requests. [disclaimer: I’m a Gunicorn developer] Less simplified: Regardless of what app server you use (Gunicorn, mod_wsgi, mod_uwsgi, cherrypy) any sort of non-trivial deployment will have something upstream that will handle the requests that your Django app …

Read more

__init__() got an unexpected keyword argument ‘user’

You can’t do because you have an __init__ method that does NOT take user as argument. You need something like Update But, as bruno has already said it, Django’s models.Model subclass’s initializer is best left alone, or should accept *args and **kwargs matching the model’s meta fields. So, following better principles, you should probably have something like Note – If you weren’t using temp as a keyword argument, e.g. LivingRoom(65), then …

Read more

Line is too long. Django PEP8

It’s “correct”, PEP8 just flags lines over 79 characters long. But if you’re concerned about that, you could write it like this: Or this: Or, really, any other style that would break the single line into multiple shorter lines.

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

What is related_name used for?

The related_name attribute specifies the name of the reverse relation from the User model back to your model. If you don’t specify a related_name, Django automatically creates one using the name of your model with the suffix _set, for instance User.map_set.all(). If you do specify, e.g. related_name=maps on the User model, User.map_set will still work, but the User.maps. syntax is obviously a bit cleaner and less clunky; so for example, if you …

Read more

Error loading MySQLdb module: No module named ‘MySQLdb’

MySQLdb is only for Python 2.x. You can’t install in Python 3.x versions. Now from your question i can see that you are working with Django. In this case you have three alternatives, from Django mysql notes: mysqldb mysqlclient mysql-connect-python This gives to you two alternatives, mysqlclient and mysql-connect-python, The first one requires compilation from extensions …

Read more