This is something new.
I get this error when submitting form.
I have another form with one textfield that works fine.
Its this one that causes errors.
Field 'id' expected a number but got 's'. What does "s" mean? Where is it coming from?
What does it mean?
Is it because it is expecting an “id” but i’m sending a “slug” instead?
If so, how can i make it work by sending an “id” and at the same time make sure that the “slug” is displayed in the URL address?
I already tried fixing this by deleting migrations and making a new migration and tried it fresh and still not fixed.
views.py
def forms_testing(request):
if request.method == 'POST':
add_book_form = AddBookForm(request.POST)
if add_book_form.is_valid():
add_book_form.save()
return redirect('forms_testing:forms_testing')
else:
add_book_form = AddBookForm()
return render(request,'forms_testing/forms_testing.html', {
'add_book_form':add_book_form
})
urls.py
path('book/<slug:book>/', views.book, name='book'),
models.py
class Book(models.Model):
title = models.CharField(max_length=300,blank=True)
slug = models.SlugField(max_length=300,blank=True)
author = models.ManyToManyField(User, null=True,blank=True)
genre = models.ManyToManyField(Genres, null=True, blank=True)
edition = models.CharField(max_length=300,blank=True)
format_type = models.CharField(max_length=300,blank=True)
languages = models.ManyToManyField(Languages, max_length=300,blank=True)
featured_image = models.ImageField(upload_to='media/FEATURED_IMAGES/',blank=True)
description = RichTextField(max_length=30000,blank=True)
published_date_re = models.DateTimeField(auto_now_add=False, blank=True)
published_date_or = models.DateTimeField(auto_now_add=False, blank=True)
publisher = models.ManyToManyField(Publisher,max_length=300,blank=True)
isbn = models.CharField(max_length=100, blank=True)
isbn_10 = models.CharField(max_length=100, blank=True)
isbn_13 = models.CharField(max_length=100, blank=True)
pages = models.CharField(max_length=300,blank=True)
amazon_link = models.URLField(max_length=2000,null=True,blank=True)
walmart_link = models.URLField(max_length=2000,null=True,blank=True)
awards_prizes = models.ManyToManyField(AwardsPrizes,max_length=400,null=True,blank=True)
def get_absolute_url(self):
return reverse('forms_testing:book', args=[self.slug])
def __str__(self):
return self.title
is there anything out of place?
please help.