Answer the question
In order to leave comments, you need to log in
How to add a service module and a specialist module to the admin panel in python django?
in models.py I wrote the service class and specialists
from django.db import models
class услуги(models.Model):
title = models.TextField()
class Специалисты(models.Model):
title = models.TextField()
from django.urls import path, include
from django.views.generic import ListView, DetailView
from news.models import Специалисты, услуги
urlpatterns =[
path('', ListView.as_view(queryset=услуги.objects.all().order_by("-title")[:20], template_name="news/услуги.html")),
path('', ListView.as_view(queryset=Специалисты.objects.all().order_by("-title")[:20], template_name="news/специалисты.html")),
]
from django.urls import path, include
from django.views.generic import ListView, DetailView
from news.models import Специалисты, услуги
urlpatterns =[
path('', ListView.as_view(queryset=Специалисты.objects.all().order_by("-title")[:20], template_name="news/специалисты.html")),
path('', ListView.as_view(queryset=услуги.objects.all().order_by("-title")[:20], template_name="news/услуги.html")),
]
Answer the question
In order to leave comments, you need to log in
If we figured out the Cyrillic, it should not be in the princepe, then let's move on to the problem.
You have 2 identical patches, django goes to the first one and does not go further. Therefore, only one is displayed. Or specialists or services, whichever comes first.
To display both one and the other, you need to pull them out, for example, in a function.
def you_function(request):
specialists = Specialists.objects.all()
services = Services.objects.all()
data = {'s': specialists, 'services': services}
return render(request, 'name.html', data')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question