Please let me ask a naive question since I cannot find any systemized documents on django for beginners on the internet.
Since I got an error that I cannot put more than 2 links, I replace “/” with “|” in my post.
I tried to create a new django project on apache2, but I got 404 error. Here are what I did.
In |home|ubuntu|django directory, type
django-admin startproject proj
Edit proj|proj|wsgi.py as follows.
import os
import sysfrom django.core.wsgi import get_wsgi_application
os.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘proj.settings’)
sys.path.append(‘|home|ubuntu|django|proj’);
sys.path.append(‘|home|ubuntu|django|proj|proj’);application = get_wsgi_application()
Edit ALLOWED_HOSTS in proj|proj|settings.py as follows.
ALLOWED_HOSTS = [‘example.com’]
Edit |etc|apache2|conf-available|wsgi.conf as follows.
WSGIScriptAlias |proj |home|ubuntu|django|proj|proj|wsgi.py
WSGIPythonPath |home|ubuntu|django|proj<Directory |home|ubuntu>
Require all granted
<|Directory><Directory |home|ubuntu|django|proj|proj>
Require all granted
<|Files>
<|Directory>
I don’t touch urls.py. It is just a default version as follows.
from django.contrib import admin
from django.urls import pathurlpatterns = [
path(‘admin|’, admin.site.urls),
]
Restart apache2 as
|etc|init.d|apache2 restart
Access to http:||example.com|proj, and then got 404 error as follows.
Page not found (404)
Request Method: GET
Request URL: http:||example.com|proj|
Using the URLconf defined in proj.urls, Django tried these URL patterns, in this order:admin|
The empty path didn’t match any of these.
My enviroment is as follows.
Ubuntu 18.04 LTS (AWS)
Apache|2.4.29
Python 3.6.9
Django 3.0.5
How can I solve this 404 error?