clean_title () отсутствует 1 обязательный позиционный аргумент: 'title'
Я вижу эту проблему и не знаю, как ее решить. Можете ли вы помочь мне?
Здесь некоторые части моего models.py
class Post(models.Model):
kategori= models.ManyToManyField(Category,related_name='post',verbose_name='Kategoriler',help_text='Başlık giriniz')
title= models.CharField(max_length=120,blank=False,verbose_name='Başlık',help_text='Baslik giriniz')
slug = models.SlugField(max_length=122,default='', null=False, verbose_name='Slug Alani',editable=True)
icerik= models.TextField(verbose_name='icerik',help_text='İcerik giriniz')
def __str__(self):
return '%s' % (self.title)
def get_slug(self):
return self.slug
def unique_slug(self,new_slug, orijinal_slug, index,):
if Post.objects.filter(slug=new_slug):
new_slug='%s-%s' %(orijinal_slug,index)
index+=1
return self.unique_slug(new_slug=new_slug, orijinal_slug=orijinal_slug, index=index)
return new_slug
def save(self, *args, **kwargs):
if self.slug =='':
index = 1
new_slug = slugify(self.title)
self.slug = self.unique_slug(new_slug=new_slug , orijinal_slug= new_slug , index=index)
#self.slug=slugify(self.title)
super(Post, self).save(*args,**kwargs)
здесь посмотреть страницу
def post_create(request):
post_form= PostForm()
if request.method=='POST':
post_form= PostForm(request.POST,request.FILES)
if post_form.is_valid():
created_post =post_form.save(commit=True)
messages.success(request,'Post Oluşturuldu')
return HttpResponseRedirect(reverse('posts:post_detail',kwargs={'slug':created_post.get_slug(self='title')}))
return render(request,'posts/post_create.html',context={'form':post_form})
TypeError at /posts/create/
clean_title() missing 1 required positional argument: 'title'
Request Method: POST
Request URL: http://127.0.0.1:8000/posts/create/
Django Version: 2.2.6
Exception Type: TypeError
Exception Value:
clean_title() missing 1 required positional argument: 'title'
Exception Location: C:\Users\EMREKA~1\Desktop\myblog\myenv\lib\site-packages\django\forms\forms.py in _clean_fields, line 402
Python Executable: C:\Users\EMREKA~1\Desktop\myblog\myenv\Scripts\python.exe
Python Version: 3.7.5
Python Path:
['C:\\Users\\EMRE KARACA\\Desktop\\myblog',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv\\Scripts\\python37.zip',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv\\DLLs',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv\\lib',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv\\Scripts',
'c:\\users\\emre karaca\\appdata\\local\\programs\\python\\python37\\Lib',
'c:\\users\\emre karaca\\appdata\\local\\programs\\python\\python37\\DLLs',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv',
'C:\\Users\\EMREKA~1\\Desktop\\myblog\\myenv\\lib\\site-packages']