a year ago
Hello, I'm a beginner in programming, and this is my first contact with hosting, so forgive me for any mistakes:
I have a project in Django, and I can deploy it and my DB in Postgres, but unfortunately, when I access the website page, it simply shows a blank page with the message:
Not Found
The requested resource was not found on this server.
the deploy logs:
[2024-04-24 01:19:17 +0000] [7] [INFO] Starting gunicorn 22.0.0
[2024-04-24 01:19:17 +0000] [7] [INFO] Listening at: http://0.0.0.0:7522 (7)
[2024-04-24 01:19:17 +0000] [7] [INFO] Using worker: sync
[2024-04-24 01:19:17 +0000] [10] [INFO] Booting worker with pid: 10
I really don't know what I did wrong, my Procfile looks like this:
web: gunicorn arena.wsgi
the host config in settings.py:
ALLOWED_HOSTS = ['academiaarena.up.railway.app']
CSRFTRUSTEDORIGINS = [ 'https://academiaarena.up.railway.app' ]
my static and media:
STATICURL = 'static/' STATICROOT = BASEDIR / 'staticfiles' STATICFILESDIRS = [
os.path.join(BASE_DIR / 'static')
]
STORAGES = {
#…
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
},
}
MEDIAURL = '/media/' MEDIAROOT = os.path.join(BASE_DIR, 'media')
LOGINREDIRECTURL = 'academia:index'
DEFAULTAUTOFIELD = 'django.db.models.BigAutoField'
I don't know what could be going wrong, if someone could guide me I would appreciate it
10 Replies
a year ago
I'm no django expert but it would help if you could share your repo.
I can find the error, what is giving conflict is the debug:
if ENVIRONMENT == 'development':
DEBUG = True
else:
DEBUG = True
I had to change the debug from else to True, because before when it was in False it was generating that error.
Do you have any idea why?
a year ago
That error has nothing to do with DEBUG.
It would help if you could share your repo.
a year ago
That error has nothing to do with DEBUG.
It would help if you could share your repo.
lol now I have more questions, I'll send you the repository link, it's my first project so sorry for the mess😊
a year ago
Send me the domain for your project please.
a year ago
from django.contrib import admin
from django.urls import include, path
from users import views as user_views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('arena-admin/', admin.site.urls),
path('', include('academia.urls')),
path('register/', userviews.register, name='register'), path('edit-profile/', userviews.editprofile, name='editprofile'),
path('edit-password/', userviews.editpassword, name='editpassword'), path('profile//', userviews.profile, name='profile'),
path('profile-list/', userviews.profilelist, name='profilelist'), path('profile-edit-user-image/', userviews.edituserimage, name='edituserimage'),
# section 9 lecture 47
path('login/', userviews.loginuser, name='login'),
path('logout/', userviews.logoutuser, name='logout'),
]
urlpatterns += static(settings.MEDIAURL, documentroot=settings.MEDIA_ROOT)
a year ago
I'm sorry but that doesn't answer the question.
Hey, sorry for the delay in responding.
I managed to find the error in my code, just as you reported, the error was not occurring just because DEBUG = False.
What was happening was that the whitenoise line of code ('whitenoise.runservernostatic') that would go to INSTALLEDAPPS was missing, this was causing the 500 error as the static files were not being loaded correctly.
After adding this line of code, it was possible to disable DEBUG in production mode.
I appreciate you taking the time to help me, and again, sorry for any inconvenience.
Grateful.
Status changed to Solved railway[bot] • 12 months ago