Traceback:
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ core \ handlers \ exception.py" во внутренней 34. response = get_response ( запрос)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ core \ handlers \ base.py" в _get_response 115. response = self.process_exception_by_middleware (e , запрос)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ core \ handlers \ base.py" в _get_response 113. response = wrapped_callback (request, * callback_args, ** callback_kwargs)
Файл "C: \ Users \ Nishant \ Desktop \ blog \ blogs \ views.py" в blogcat 19. blogs = Blog.objects.filter (cat = cat_title)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ manager.py" в manager_method 82. return getattr (self.get_queryset (), name) (* args, ** kwargs)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ query.py" в фильтре 892 вернуть self._filter_or_e xclude (False, * args, ** kwargs)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ query.py" в _filter_or_exclude 910. clone.query.add_q (Q (* args, ** kwargs))
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ sql \ query.py "в предложении add_q 1290., _ = self._add_q (q_object, self.used_aliases)
Файл" C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site- пакеты \ django \ db \ models \ sql \ query.py "в _add_q 1318. split_subq = split_subq, simple_col = simple_col,
File" C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site -packages \ django \ db \ models \ sql \ query.py "в build_filter 1251. condition = self.build_lookup (lookups, col, value)
Файл" C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ sql \ query.py "в build_lookup 1116. lookup = lookup_class (lhs, rhs)
File" C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ lookups.py "в init 20. self. rhs = self.get_prep_lookup ()
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ fields \ related_lookups.py" в get_prep_lookup 115. self.rhs = target_field.get_prep_value (self.rhs)
Файл "C: \ Users \ Nishant \ Desktop \ myvenv \ lib \ site-packages \ django \ db \ models \ fields__init __. py" в get_prep_value 966.
return int(value)
Exception Type: ValueError at /blogcat/music/
Exception Value: invalid literal for int() with base 10: 'music'
urls.py Это URL моих проектов .py
from django.contrib import admin
from django.urls import path
from django.conf.urls.static import static
from blogs import views
from django.conf import settings
urlpatterns = [
path('blogcat/<str:cat_title>/',views.blogcat,name='blogcat'),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
models.py
class Files(models.Model):
files=models.FileField(upload_to='blog/',blank=True,null=False)
title=models.CharField(max_length=30)
des=models.TextField()
def __str__(self):
return self.title
class Category(models.Model):
title=models.CharField(blank=True,max_length=20)
des=models.TextField()
image=models.ImageField(upload_to='cat/')
def __str__(self):
return self.title
class Blog(models.Model):
title=models.CharField(max_length=40)
cre_date=models.DateField()
pub_date=models.DateField()
desc=models.TextField()
image=models.ImageField(upload_to='blog/',blank=True,null=True)
author=models.CharField(blank=True,choices=author,max_length=30)
cat=models.ForeignKey(Category, verbose_name="Category",
blank=True,on_delete=models.CASCADE,null=True)
files=models.ForeignKey(Files, verbose_name="Files",on_delete=models.CASCADE,blank=True,
null=True)
def __str__(self):
return self.title
views.py views.py блогов приложения Получение ошибки с запросом: blogs = Blog.objects.filter (cat = cat_title)
from django.shortcuts import render, redirect, get_object_or_404
from .models import Blog,Category
def blog(request):
blog= Blog.objects.all()
cat= Category.objects.all()
return render(request, 'blogs/allblogs.html', {'blog':blog,'cat':cat})
def post(request,post_id):
post= Blog.objects.filter(pk=post_id)
cat= Category.objects.all()
return render(request, 'blogs/post.html', {'post':post})
def blogcat(request,cat_title):
print(cat_title)
blogs=Blog.objects.filter(cat=cat_title)
print(blogs)
return render(request,'blogs/blogcat.html',{'blogs':blogs})