This question seems to have been asked many times but all the solutions I have checked haven't yet worked for me. I am running nginx on a Ubuntu 14.04 server with Django 1.6.1 installed. I am attempting to use the default django admin backend for a project (usually at localhost/admin/).
The issue I run into is OperationalError at /admin/ attempt to write a readonly database
(Update when I changed chmod permissions for the db.sqlite3 file the error now reads OperationalError at /admin/ unable to open database file but I have checked every option on the Django Newbie Mistakes website for the answer and no dice)
Some answers talked about the r+w+x permissions for the generated database file db.sqlite3 as far as I can tell even 777 on the db file doesn't do anything so I've kept it at 656.
As far as I can tell the django project works find (all pages render fine, the /admin page renders without css. When i attempt to login using localhost/admin/ and click submit I get the django debug page with the error). They are all owned by root:root. I have tried changing permissions for every file and directory to be owned by www-data:www-data but nothing.
I have even tried changing the settings.py to have an absolute path to the db instead of os.path.join(BASE_DIR, 'db.sqlite3')
I think its down to an ownership problem but I'll take any help.
After all that hassle and 2+ hours of banging my head against a wall, the answer for the archives...
I was using gunicorn, I took a cookie cutter set up from Digital Ocean which made the user django. I thought it the cookie cutter approach would be a shortcut which was easy to modify and skipped the boring bits. It turns out in /etc/init/gunicorn.conf setuid and setgid was set to the user django. My fault for not reading the documentation and assuming these meant little.
If you are having this problem either delete setuid or setgid or set them to www-data.
This error usually caused by running the server as a different user (i guess you are running a linux machine). If you have created the project as a root/administrator and running the server as a user with lower status, then you will get the error.
try running the server with sudo permission, i.e
sudo python3 manage.py runserver
Related
I'm working on a django project, after changing some templates, it works on my local machine, but after uploading to production server (+restarting Apache) webserver shows the old code!
Its about few specific base template files.
I have tried to restart server, reload webserver and reinstall venv.
None of it worked.
Do I use template/fragment caching? No.
Do I use apache's caching? No.
UPDATE :
i just made some changes to one of another app's template files and uploaded it
after refresh, it updated right away!
now i am pretty sure that this problem is happening to only 1 of my apps
In my case, using gunicorn, I solved it this way:
sudo systemctl restart gunicorn-django-tutorial.service
The changes are not shown in production because gunicorn needs to reload the configuration.
A restart of the web server is not needed (I'm using Nginx).
I am developing a Django application in Atom locally, and then on pythonanywhere, when I'm ready, I'm doing a GIT PUSH command after syncing those changes to GITHUB. The problem is, at some point, those changes which were pushed through from my local development env have overwritten all my live users with just the local dummy users I've been using for testing and development.
Basically, I'm testing the login and registration system locally, logging in and registering with lots of dumb emails. Once I was happy it was working, I synced the Django code I'd changed to GITHUB (with the desktop app) and then did a GIT PUSH command on a PythonAnywhere (my server) console. The sqlite DB is included in those updates/sync - is that correct? Or should it just be totally ignored?
I just realised, that one (perhaps all?) pushes have overwritten my sqlite DB, and there were perhaps 30 or so actual users who had signed up on the website whose data is no longer registered on the site. I managed to find a trace of them in the Django Admin logs, and I've found the version history of the Sqlite DB on GITHUB, but my question is - how do I avoid this happening?
What is the workflow to avoid this situation in the future? And is there a command I can run in shell to get those users back into my 'live' database from the backedup SQlite file?
I know this is a simple question, but I'm new to development and I'm slowly getting there with troubleshooting the code, but versioning, GIT, and workflow are tricky things to get my head around.
Hi I am new to Django and have been googling for a whole day without any success.
Basically there is a live/working website built with AngularJS, Django and PostgreSQL (Ubuntu 14.04) and I am trying to download all the files and clone the site into my localhost (Ubuntu 14.04).
After I downloaded the folder and finished install the required packages on my localhost, I run:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
The server runs without reporting any errors.
However, some of the links are directed to a 404 page, such as this:
http://127.0.0.1:8000/city/chicago
Whereas in the live site, it would direct to the correct working page.
Can someone tell me what may have gone wrong in the process?
Thanks.
Try editing the settings.py file set the DEBUG value to True. Instead of a 404 you should get a full debug of the actual request and see what exactly is missing (I suspect missing data as #NightShadeQueen pointed).
Also you might have a look at django debug toolbar which prints the executed sql queries as well and run them against your local database to see what exactly they return.
I'm a rookie to Django and Django CMS but definitely enjoying the framework thus far.
I have a question regarding deploying a Django CMS project on Ubuntu Server. When we deploy it on the Ubuntu desktop version, the project works just fine without any issues, but on the server, we run into trouble with the CMS admin interface. Although the content of the sidebar is functional, it does not collapse anymore and once we select an option from the CMS toolbar, the modal window that pops up is unresponsive.
Initially i thought there was an issue with my project, but then we just installed a basic django CMS project on the server itself, without any other apps, and the issue still persisted. I am using Django 1.7.3, Django CMS 3.0.9, and Ubuntu Server 14.04. I am unable to determine what the issue is and no errors are thrown. Tried searching the web for this issue, but we couldn't find any similar issues.
UPDATE:
So i was able to narrow down the problem here to some extent. Found out that the problem was with the browser. A few versions of chrome were giving me these issues. IE and Firefox were working just fine.
UPDATE 2:
As #mkoistinen suggested, this problem had been occuring on devices with touch-screens and mouse capabilities. Please look at this issue.
I run Django and CMS, etc. on Ubuntu servers all day long, so there is not an issue with the OS for sure.
Having said this, running Django locally can be very different than running it in a production environment. Locally, runserver takes care of a lot of things you have to address yourself on a server under the WSGI implementation of your choice.
It sounds like you have WSGI configured well enough to get Django to respond, but you may be having trouble with your STATIC and MEDIA paths. Definitely check the settings for these items.
Another thing to look at is, did you run python manage.py collectstatic on the server? If not, the static files from your packages will not have been copied into your STATIC_ROOT, which could easily lead to the condition you describe above.
If your client is both touch- and mouse-capable, please note that this is an issue that is fixed in 3.0.10.
recently I started a small Django project that I developed on a local machine using a SQLite3 database and the integrated development server. I now copied the whole project to a server running Debian.
Everything worked well as long as I kept using the SQLite3 database. Now I wanted to switch to a local MySQL database, so I changed the settings.py file in my project's root folder, created the database and added a user. I then ran syncdb and it created the needed tables without any problems.
Now I wanted to use the app, but I keep getting errors, because Django can not find the tables - neither the 'standard tables' like django_sessions nor my own tables - even though they are there (I checked the database).
The one thing that seems awkward about the DatabaseError pages I get is the following line:
Exception Location: /usr/local/lib/python2.6/dist-packages/django/db/backends/sqlite3/base.py in execute, line 234
It seems like Django is still using the SQLite3 backend even though I set it to use the MySQL backend.
The other thing that nearly makes me freak out is this: I deleted the data.sqlite file in my app's root folder using rm. But when I use my app, the file is being recreated!
Can anyone tell me where I went wrong?
When running in production with mod_wsgi or mod_python, new code isn't incorporated until you reload/restart the webserver.
If you are using apache with mod_wsgi, you can also touch the wsgi.py file to restart the python code only.
If running on apache run "sudo /etc/init.d/apache2 reload" everytime you make a change.