I
I
ixotep2019-03-10 06:59:25
Django
ixotep, 2019-03-10 06:59:25

Django error object has no attribute 'save_m2m' what is the error?

Hi all! already broke my head with this error ..
The essence of the question: from the Django admin panel I try to add a new post and the following error occurs:

AttributeError at /admin/blog/posts/add/
'PostsForm' object has no attribute 'save_m2m'
Request Method:	POST
Request URL:	http://127.0.0.1:8000/admin/blog/posts/add/
Django Version:	2.1.7
Exception Type:	AttributeError
Exception Value:	
'PostsForm' object has no attribute 'save_m2m'

models.py:
class Posts(models.Model):
    # category = models.ForeignKey(Category, on_delete=models.PROTECT, related_name='category')
    img_post = models.ImageField(upload_to='image/img_post/', verbose_name='Картинка поста', blank=True)
    title = models.CharField(max_length=200, verbose_name='Заголовок')
    date = models.DateTimeField(auto_now=True, db_index=True, verbose_name='Дата поста')
    post = models.TextField(max_length=5000, verbose_name='Пост')
    slug = models.SlugField(unique=True, blank=True, verbose_name='Транслит')
    approved = models.BooleanField(verbose_name='Опубликовать')
    #
    # def __unicode__(self):
    #     return self.title
    #
    # def save(self, *args, **kwargs):
    #     self.slug = '{}'.format(slugify(self.title))
    #     super(Posts, self).save(*args, **kwargs)
    #
    # class Meta:
    #     verbose_name = 'Пост'
    #     verbose_name_plural = 'Посты'
        # ordering = ['date']
#

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ixotep, 2019-03-11
@ixotep

I just had to recreate the project, thanks everyone!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question