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
Related
I have created a new Heroku site and I am developing it on my Linux box, using Django. The standard "getting started" site Heroku created for me is called "gettingstarted". How can I change that / configure Heroku to forget about it?
I was reading through the Django tutorial, which explains how to create a new site (django-admin startproject my_site). I did this successfully for a demo project. Then I tried to do it under the Heroku directory, because I wanted a better name for my site than "gettingstarted". I noticed that every time I start the Heroku server under my project, it says ...using settings 'gettingstarted.settings'. I found that this is configured in manage.py and I change it.
This is the directory layout I have
/some/path/heroku_random_name/gettingstarted/settings.py
/some/path/heroku_random_name/my_site/settings.py
/some/path/heroku_random_name/my_app
This is what I have in
/some/path/heroku_random_name/manage.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_site.settings')
so I would expect that the site that matters is my_site.
I got it to the point where I can run the site successfully on my local machine, and I can tell that it using the settings from my_site. But when I deploy the project to Heroku, it does not recognize my_app until I register it in gettingstarted/settings.py. In other words, when running in Heroku, it is still using gettingstarted as the site to run.
I am new to all this, so I left gettingstarted in the project, because I am afraid to break things. But how can I configure Heroku to execute settings from my_site and not from gettingstarted?
Found it: it's configured in Procfile.
It's confusing because it's configured in one place for running locally and in a different place for running hosted at Heroku.
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.
I'm using Djnago 1.8.17. I have deployed the code to a remote server, checked that it is up to date, but the changes do not refresh in the web page.
Things I've tried so far:
Restarted gunicorn and nginx
Using manage.py instead of gunicorn
Clear memcached
Restarted server
Delete all .pyc files
Open in incognito
I've this module that is working fine in other servers, but for some reason this one is showing an old version.
The problem may come from static files
https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/
you try to update them with
python manage.py collectstatic
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.
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