Answer the question
In order to leave comments, you need to log in
The code does not work only on the server, what could be the reason?
There is a django site with pretty simple routing, this is what the root urls.py looks like :
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('', include('pages.urls')),
path('services/', include('services.urls')),
path('bookings/', include('bookings.urls')),
path('admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='services'),
path('<int:service_id>', views.service, name='service'),
]
from django.shortcuts import render, get_object_or_404
from .models import Service
def index(request):
services = Service.objects.all()
context = {
'services': services
}
return render(request, 'services.html', context)
def service(request, service_id):
services = Service.objects.all()
service = get_object_or_404(Service, pk=service_id)
context = {
'services': services,
'service': service
}
return render(request, 'service.html', context)
<a href="{% url 'services' %}" class="nav-link">Услуги</a>
Answer the question
In order to leave comments, you need to log in
One of the images used on this page was not uploaded correctly to the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question