title: django Models One Author to Multiples Books Relationship
body: <p>I'm trying to create a relationship on Django on models.py one Author could be the writer of multiples books for a Bookshop project. Please find below how the models.py looks. I'm afraid is not working correctly. Thank you.</p>
  <pre><code>from django.db import models
  from django.utils import timezone
  from django.urls import  reverse
  # Create your models here.
  class Category(models.Model): # books categories
  
      name = models.CharField(max_length=200,db_index=True)
      slug = models.SlugField(max_length=200,unique=True)
      
      class Meta:
          ordering = ('name',)
          verbose_name = 'category'
          verbose_name_plural = 'categories'
  
      def __str__(self):
          return self.name
      
      def get_absolute_url(self):
          return reverse('category_detail',args=[self.slug])
  
  
  class Product(models.Model): # books as products
      category = models.ForeignKey(Category,related_name='products',on_delete=models.CASCADE)
      author = models.ForeignKey(Author,related_name='authors',on_delete=models.CASCADE) 
      book_id = models.CharField(max_length=10, db_index=True, blank=True) 
      name = models.CharField(max_length=200, db_index=True)
      slug = models.SlugField(max_length=200, db_index=True)
      image = models.ImageField(upload_to='products/%Y/%m/%d',blank=True)
      image2 = models.ImageField(upload_to='products/%Y/%m/%d',blank=True)
      image3 = models.ImageField(upload_to='products/%Y/%m/%d',blank=True)
  
      description = models.TextField(blank=True)
      price = models.DecimalField(max_digits=10, decimal_places=2)
      available = models.BooleanField(default=True)
      created = models.DateTimeField(default=timezone.now)
      updated = models.DateTimeField(auto_now=True)
      
      class Meta:
          ordering = ('-created',)
          index_together = (('id', 'slug'),)
      
      def __str__(self):
          return self.name
  
      def get_absolute_url(self):
          return reverse('product_detail',args=[str(self.slug)])
        
  
  class Author(models.Model): # book's author
      first_name = models.CharField(max_length=50)
      last_name = models.CharField(max_length=50)
  
      def __unicode__(self):
          return self.first_name + &quot; &quot; + self.last_name
  </code></pre>