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

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.

Related

Django admin misbehaves after adding for django.contrib.sites on server

Django Admin Site was working fine on local server.
But the same thing when deployed on server. Admin CSS misbehaves See Screenshot Admin panel screenshot on server
admin panel site also working fine on mobile responsive view or small screens
On localhost it looks something like this.
I have ran collect static several times on server but nothing happens.
Tried Clearing Cache many time.
Nothing worked
But localhost seems to work fine
I find answer myself.
Initially a old version of site already working on server.
Then i added django.contrib.sites for django.contrib.sites
Upon adding that when update is pushed to server then
python manage.py collectstatic
command does not completely replace old files.And It doesn't work well with old files.
So run collectstatic command on local
upload generated folder to
server to avoid any such issues

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 admin login broken when using apache wsgi

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!

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

How to use django "site" framework on google app engine

I'm going to answer my question. I ask this so that other people who is still searching on how to create a django "site" will have a clear answer.
The django documentation had show how to use the django site framework. But strangely, after googling for quite a while, I can't find a good instruction on how to install the site framework. We all know to install an app, we put 'django.contrib.sites' on the INSTALLED_APP list. But how to add the site? Using the admin interface will result in error that say that the site framework is installed but no site is configured (Duhh!). So, we have to assign SITE_ID on the setting.py. But what is the id? From some source, we know that the it has installed a default site by the domain example.com. But still what is the id? setting it to 0 or 1 will also result in error.
Just read the link:
http://www.allbuttonspressed.com/projects/djangoappengine
Definitely the best tutorial I have found:
Flying with Django on GAE
With this I had my site on appspot after about half an hour.
The answer is....
First, put 'django.contrib.sites' on the installed app list like usual.
Then run
python manage.py syncdb
(At you project directory that is). Then, run:
python manage.py shell
Then, use the following sequence of code:
>>>import django.contrib.sites.models as mod
>>>mod.Site.objects.all().count()
Make sure it prints out 1. If it doesn't you probably haven't run syncdb properly.
>>>msite=mod.Site.objects.all().get()
>>>msite.pk
It will print your default site id. SITE_ID (in setting.py.)to the number given. That should do it. At least on development server.
ps: Strangely, mine is 383L. Not 0 or 1. This is probably google app engine with django nonrel specific.