Django stuck on default page - python

I have django set up on a server, but it will only return the default "Welcome to Django" page.
I also have django set up on a local machine, and I use git to push the files to the server.
Both the server and local machine are configured with apache/wsgi.
On the local machine it will display the webapp as intended, but on deployment to the server, it shows nothing but the default page.
Restarting apache on the server and even an error in the django project have not made a difference.
Any ideas?

i am assuming you have django set up locally. if that is so, then you are using localhost. it is suppose to show the welcome page unless you configure on the url.py to redirect it to somewhere else. it would be useful if you showed us the url.py. if the welcome page or the url.py has not been altered, then i dont know what else it would change to besides the default welcome page.

Related

Running Django in IIS

I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?

How to deploy django website in ubuntu 18.04 + plesk + apache in digitalocean droplet

In my droplet is running several PHP websites, recently I tried to deploy a Django website that I build. But it's doesn't work properly.
I will explain the step that I did.
1, Pointed a Domain name to my droplet.
2, Added Domain name using Plesk Add Domain Option.
3, Uploaded the Django files to httpdocs by Plesk file manager.
4, Connected the server through ssh and type python manage.py runserver
0:8000
5, My Django Website is successfully running.
Here are the real issues occurs, We need to type exact port number to view the website every time. Eg:- **xyz.com:8000 **
As well as the Django webserver is down after sometimes.
I am newbie to Django all I have experience in deploying a PHP website. If my procedure is wrong please guide me to correct procedure.
Thanks in Advance.
Django Runserver is not a production one, it should be used only for development. That's why you need to explicitly type in the port and it sometimes go down because of code reload or other triggers.
Check Gunicorn for example, as a production server for Django applications. (there are other options also)
I suggest following this guide. Covers initial setup of django with gunicorn and nginx which is essential for deployment, you don't have to add the port to access the site. It doesn't cover how to add the domain but it seems you already know how to add the domain though.

Django Admin Interface - Privileges On Development Server

I have an old project running (Django 1.6.5, Python 2.7) live for several years. I have to make some changes and have set up a working development environment with all the right django and python requirements (packages, versions, etc.)
Everything is running fine, except when I am trying to make changes inside the admin panel. I can log on fine and looking at the database (sqlite3) I see my user has superuser privileges. However django says "You have no permissions to change anything" and thus not even displaying any of the models registered for the admin interface.
I am using the same database that is running on the live server. There I have no issues at all (Live server also running in development mode with DEBUG=True has no issues) -> I can only see the history (My Change Log) - Nothing else
I have also created a new superuser - but same problem here.
I'd appreciate any pointers (Maybe how to debug this?)
Finally, I found the issue:
admin.autodiscover()
was commented out in the project's urls.py for some reason. (I may have done that trying to get the project to work in a more recent version of django) - So admin.site.register was never called and the app_dict never filled. index.html template of django.contrib.admin then returns
You don't have permission to edit anything.
or it's equivalent translation (which I find confusing, given that the permissions are correct, only no models were added to the admin dictionary.
I hope this may help anyone running into a similar problem

How to start a django app

I'm trying to use django-ios-notifications to server PUSH notifications via APNS (https://github.com/stephenmuss/django-ios-notifications). I've never used Django before. I've followed the instructions on the modules github page, but have'nt been able to get it working. I've done the following;
*installed required package and django
*added 'ios_notifications', to my INSTALLED_APPS settings file
*synced my local MySQL server with django (a load of new tables were created, for both django and django-ios-notifications, so it appears to be installed correctly, which I was thrilled about)
*start django server
However when I go to the modules config page (URL below) I just see the default 'It worked!
Congratulations on your first Django-powered page.' holding page, not the admin page I expected. (the tutorial on the github page descried a form)
http://127.0.0.1:8000/admin/ios_notifications/apnservice/add/
I guess I need to configure something in djange, I read over the first few pages on the django tutorial but I couldn't see any mention of using installed modules. I'm sure this is a very simple problem to solve, so if anyone could point me in the right direction that would be fantastic.
https://github.com/stephenmuss/django-ios-notifications
You don't seem to have activated Django's admin interface, which you need to access the admin forms. There are concise instructions in the documentation. You can switch to a different version of Django in the lower right corner, if you aren't using 1.5.

Apache server does not connect to Django

So, I'm running Apache2 on a Linux machine, and I'm trying to serve pages with Django 1.3. I found a guide to do this here.
I have the django.wsgi configured, the settings.py configured, and the database created and successfully in sync with Django. However, when I try to visit the website, I am shown a page served by Apache, instead of Django. I get no errors/warnings at all.
I put print statements in both django.wsgi and settings.py (since they're both just python files), but nothing gets printed.
Does anyone have any idea as to what may be going wrong or any diagnostic steps I might be able to take?
Thanks!
As everyone has said in the comments, you need to add a WSGIServerAlias directive to the Apache configuration before anything will work. Otherwise, Apache can't possibly know to use WSGI to serve your site.

Categories