Django admin login broken when using apache wsgi - django

I am facing an interesting problem where I'm unable to login to the admin page of my app when I access it through wsgi in apache.
However when I try to access it through the django dev server it works just fine.
I don't get a wrong login warning I just see an get redirected to the same page as if nothing happened. Putting in wrong credentials does prompt that I have put in wrong credentials.
The only difference between dev server and the apache should be the I'm using virtualenv when creating the django dev server.
I've made sure to remove the standard paths from the sys.path and make it identical to when the virtual env is invoked.
I'm not seeing anything in the apache logs either.
Thanks!

Related

Server Error (500) Django App on AWS server

Good day,
i have currently my django project running on an aws server. I have used Nginx and configured it all. The application is running, but when i try to login via the login page i have created or try to login via the admin panel it gives me a Server Error (500). I have my DEBUG=False and added my server dns to ALLOWED_HOSTS. As for the Database. I have got my SQL Database running on an Azure server and used environment variables (that i have permanently set in my ubuntu terminal) to get my password and username.
I have also tried to set DEBUG to False and trying to figure out the issue when running python manage.py runserver so i could experiment with it on my localhost, but no luck. I cant access 127.0.0.1 eventhough i have added it to my Allowed hosts.
How could i see what the error is? Thank you in advance
Ok, so fixed it!
After each change, you simply run the command sudo supervisorctl reload in your powershell after you ssh'ed into your aws ec2 server.
As for seeing what the error is, simply set DEBUG=True

Django apps not showing in admin when site is deployed to server

I have a test site which I am (trying) to get deployed to an Ubuntu 16.04 server.
If I run the site using the Django server (python manage.py runserver 0.0.0.0:8000), I can see all of the apps when I visit the admin page as the superuser, and everything is fine.
However, when I run the site normally, using wsgi, the only apps I can see (and interact with) in the admin are for the users and groups. None of the apps I have created are visible, and if I try and navigate to a change list page for one of them for example, I get a page not found.
I believe my mod_wsgi set up is ok, in that I can view the admin and login, so I don't believe this is the problem.
Perhaps it's a permissions issue?
Any help much appreciated!
UPDATE
In the django shell, on the server, I have run
from django.conf import settings
print(settings.INSTALLED_APPS)
and this prints out the list of apps I would expect to be displayed in the admin
UPDATE 2
Having come back to the live site overnight, the apps are now showing in the admin - but I have no idea why, because they weren't yesterday and I haven't made any changes.

Django models missing. Why my django models disappeared on production server, if on development server runs fine?

im running django development server and all models works fine..
But when i have configured and run apache through wsgi, only "Groups" and "Users" could be administrated, my own models disappears:
screenshot of admin pages from development server and production server
Why, please?
(After first comments here is my edit:)
I want to use django on localhost only, to fill and administrate small database file. Project is not intended for web hosting yet. I have no html views and templates defined. So I have try some simple view for testing purposes only, and problem is the same. Web server cant find some includes..:
image2: simple view also dosen't work
Make sure your production settings file has all the apps included. Normally when you don't see your admin models its due to the app missing from the list of apps included in settings.py.
Had the exact same problem. Had to restart uwsgi
sudo service uwsgi restart
Maybe for you it's wsgi or apache. Something in the pipeline needs to know you changed some python code.

Django + GAE + Google Cloud SQL authentication issue in Windows

I've followed all steps required to configure Django with GAE + Google Cloud SQL (on Windows 7) but I am unable to authenticate (OAuth2) and run syncdb remotely. When I run manage.py syncdb the browser pops up and I am requested to allow access, but when I do that nothing happens. The browser is forwarded correctly to my local django instalation (the typical It worked! screen) but no OAuth2 token is in %USERPROFILE%\ and the console gets frozen:
C:\Users\me\myproject>python manage.py syncdb
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?state=None&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=my_id.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice&access_type=offline
If your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver
There is no error message and I have to kill the console.
Anybody has faced a similar issue? Is there any log somewhere in GAE I can check?
I had the same problem, only on OS X.
I never figured out why, but it went away after a reboot.
I had the same issue, but it was because I had local appengine server running while I was running manage.py syncdb. Shutting it down and trying again worked as intended.
hope that helps.

Django Apache2 mod_wsgi flatpages admin not working

I finally got apache2 with mod_wsgi working on Linux (havent much luck with windows :D) and everything works fine, but now when I added flatpages to my project, I found out that Apache doesn't seem to be aware of URL for admin when trying to create new flatpage via admin.
It says
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1/admin/flatpages/flatpage/1/
And now I noticed that when I'm on admin front page, and hit F5 again and again, flatpages admin appears and disappears, but nothing like this happens when using dev server, so I'll try to create new project with default setting and see what it'll do in apache and in dev server, did anyone came across this kind of error?
The Django dev server auto-reloads your code when you change it, but Apache does not.
If you are running mod wsgi in daemon mode, you can reload the code by touching the wsgi script.
touch myproject/mysite.wsgi
Otherwise, you may have to restart apache. For example
/etc/init.d/apache2 restart