Django ALLOWED_HOSTS IPs range

No, this is not currently possible. According to the docs, the following syntax is supported: [‘www.example.com’] # Fully qualified domain [‘.example.com’] # Subdomain wildcard, matches example.com and www.example.com [‘*’] # Matches anything If you look at the implementation of the validate_host method, you can see that using ‘*’ by itself is allowed, but using * … Read more

django settings per application – best practice?

The simplest solution is to use the getattr(settings, ‘MY_SETTING’, ‘my_default’) trick that you mention youself. It can become a bit tedious to have to do this in multiple places, though. Extra recommendation: use a per-app prefix like MYAPP_MY_SETTING. There is a django app, however, that gets rid of the getattr and that handles the prefix … Read more

sqlite3.OperationalError: unable to open database file

Django NewbieMistakes PROBLEM You’re using SQLite3, your DATABASE_NAME is set to the database file’s full path, the database file is writeable by Apache, but you still get the above error. SOLUTION Make sure Apache can also write to the parent directory of the database. SQLite needs to be able to write to this directory. Make … Read more

Django – after login, redirect user to his custom page –> mysite.com/username

A simpler approach relies on redirection from the page LOGIN_REDIRECT_URL. The key thing to realize is that the user information is automatically included in the request. Suppose: LOGIN_REDIRECT_URL = ‘/profiles/home’ and you have configured a urlpattern: (r’^profiles/home’, home), Then, all you need to write for the view home() is: from django.http import HttpResponseRedirect from django.urls … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)