Hello, my project, which works fine on localhost, started giving 403 errors after post operations when I uploaded it to the host.
I can log in in the admin panel, when I add a new user, it does the process successfully, but I get a 403 error on the return page.
error page:
urls.py:
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.sitemaps.views import sitemap
from home.sitemap import StaticViewSitemap
sitemaps = {
'static':StaticViewSitemap
}
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("home.urls"), name="anasayfa"),
path('sitemap.xml', sitemap, {"sitemaps":sitemaps}, name="sitemaps")
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
home ursl.py:
from django.contrib import admin
from django.urls import path
from django.views.generic import TemplateView
from . import views
app_name = "home"
urlpatterns = [
path(r'', views.index, name="anasayfa")
path(r'galeri', views.galeri, name="galeri"),
]
models.py:
from django.db import models
class Galeri(models.Model):
baslik = models.CharField(max_length=255,null=True,blank=True, verbose_name="Başlık")
resim = models.ImageField(blank=True, null=True, verbose_name="Fotoğraf Ekle")
class Video(models.Model):
baslik = models.CharField(max_length=255, null=True, blank=True, verbose_name="Başlık")
video = models.FileField(upload_to="video", blank=True, null=True)
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"home",
'django.contrib.sitemaps'
]
The project was working fine in localhost, but I have such a problem when I upload it to my domain address. The pages of the site are working fine, but there is only this problem in the admin panel.
I’m sorry for my bad english. Thanks in advance for your help