When adding tags through the console produces this error (it is in the title) models.py
from django.db import models from django.shortcuts import reverse class Post(models.Model): title = models.CharField(max_length=150, db_index=True) slug = models.SlugField(max_length=150, unique=True) body = models.TextField(blank=True, db_index=True) tags = models.ManyToManyField('Tag', blank=True, related_name='posts') date_pub = models.DateTimeField(auto_now_add=True) def get_absolute_url(self): return reverse('post_detail_url', kwargs={'slug': self.slug}) def __str__(self): return '{}'.format(self.title) class Tag(models.Model): title = models.CharField(max_length=150, db_index=True) slug = models.SlugField(max_length=50, unique=True) def __str__(self): return '{}'.format(self.title) # Create your models here . I enter this into the console
from blog.models import * django_t = (title='django', slug='django') Post.tags Post.tags.add(django_t) 'ManyToManyDescriptor' object has no attribute 'add'