Я получаю эту ошибку: включенный URLconf 'liskerproject.urls', похоже, не содержит никаких шаблонов. Если вы видите допустимые шаблоны в файле, то проблема, вероятно, вызвана циклическим импортом.
liskerproject - это каталог root, содержащий root urls.py. Lisk - это еще один каталог, содержащий «url.py»
Вот как выглядят мои root url:
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import path,include
from users import views as user_views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('edit/',user_views.edit,name='edit'),
path('',include('Lisk.url')),
path('register/',user_views.register,name='register'),
path('login/',auth_views.LoginView.as_view(template_name='user_templates/login.html'),name='login'),
path('logout/',auth_views.LogoutView.as_view(template_name='user_templates/logout.html'),name='logout')
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Вот как выглядит Lisk.url:
from django.urls import path
from .views import Politics_topic,Questionpolitics,Updatepolitics,Politics_post_details,Deletepoliticspost,Profile,home
from . import views
urlpatterns = [
path('',home,name='home'),
path('about/',views.about,name = 'about Lisk'),
path('interests/',views.interests,name='interests'),
path('profile/',Profile.as_view(template_name='lisk_templates/profile.html'),name = 'profile'),
path('politics_topic/', Politics_topic.as_view(template_name='lisk_templates/politics_topic_template.html'),
name='Politics_topic'),
path('ask_politics/', Questionpolitics.as_view(template_name='lisk_templates/ask_politics_template.html'),
name='ask_politics'),
path('politicspost/<int:pk>/',Politics_post_details.as_view(template_name='lisk_templates/politics_post_details.html'),
name='politics_post_details'),
path('politicspost/<int:pk>/update/',Updatepolitics.as_view(template_name='lisk_templates/ask_politics_template.html'),
name='updatepoliticspost'),
path('politicspost/<int:pk>/delete/',Deletepoliticspost.as_view(template_name='lisk_templates/delete_politics_confirmation.html'),name ='deletepoliticspost')
]
Так выглядит Lisk.views:
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
from .models import Post, PoliticsPost
from django.contrib.auth.decorators import login_required
from django.urls import reverse_lazy
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
def home(request):
return render(request, 'lisk_templates/home_template.html')
def about(request):
return render(request, 'lisk_templates/about_template.html')
@login_required
def interests(request):
return render(request, 'lisk_templates/interests_template.html')
class Profile(LoginRequiredMixin,ListView):
model = Post
context_object_name = 'post'
ordering = ['-date_posted']
#POLITICS-------------
class Politics_topic(ListView):
model= PoliticsPost
context_object_name = 'politicsposts'
ordering = ['-date_posted']
class Politics_post_details(DetailView):
model = PoliticsPost
context_object_name = 'politicsposts'
class Questionpolitics(LoginRequiredMixin, CreateView):
model = PoliticsPost
fields =['question','description']
success_url = reverse_lazy('Politics_topic')
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
class Updatepolitics(LoginRequiredMixin,UserPassesTestMixin,UpdateView):
model = PoliticsPost
fields = ['question','description']
success_url = reverse_lazy('Politics_topic')
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
def test_func(self):
post = self.get_object()
if self.request.user == post.author:
return True
return False
class Deletepoliticspost(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
model = PoliticsPost
success_url = reverse_lazy('Politics_topic')
def test_func(self):
post = self.get_object()
if self.request.user == post.author:
return True
return False
#POLITICS-------------