from django.db import models
from django.contrib.auth.models import User
from froala_editor.fields import FroalaField
from blogapp import helpers

class BlogModel(models.Model):
  user = models.ForeignKey(User, on_delete=models.CASCADE)
  title = models.CharField(max_length=100)
  content = FroalaField()
  slug = models.SlugField(max_length=100, null=True, blank=True)
  image = models.ImageField(upload_to="blog")
  created_at = models.DateTimeField(auto_now_add=True)
  updated_at = models.DateTimeField(auto_now=True)

  def __str__(self):
    return self.title
  
  #overriding the save method
  def save(self, *args, **kwargs):
    self.slug = helpers.generate_slug(self.title)
    super(BlogModel, self).save(*args,**kwargs)
  
aeac8a66b44a52c7c1e35240a5a01327734659ae
<mask token>


class BlogModel(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def __str__(self):
        return self.title
    <mask token>

<mask token>


class BlogModel(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def __str__(self):
        return self.title

    def save(self, *args, **kwargs):
        self.slug = helpers.generate_slug(self.title)
        super(BlogModel, self).save(*args, **kwargs)

<mask token>


class BlogModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    content = FroalaField()
    slug = models.SlugField(max_length=100, null=True, blank=True)
    image = models.ImageField(upload_to='blog')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title

    def save(self, *args, **kwargs):
        self.slug = helpers.generate_slug(self.title)
        super(BlogModel, self).save(*args, **kwargs)

from django.db import models
from django.contrib.auth.models import User
from froala_editor.fields import FroalaField
from blogapp import helpers


class BlogModel(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=100)
    content = FroalaField()
    slug = models.SlugField(max_length=100, null=True, blank=True)
    image = models.ImageField(upload_to='blog')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title

    def save(self, *args, **kwargs):
        self.slug = helpers.generate_slug(self.title)
        super(BlogModel, self).save(*args, **kwargs)

from django.db import models
from django.contrib.auth.models import User
from froala_editor.fields import FroalaField
from blogapp import helpers

class BlogModel(models.Model):
  user = models.ForeignKey(User, on_delete=models.CASCADE)
  title = models.CharField(max_length=100)
  content = FroalaField()
  slug = models.SlugField(max_length=100, null=True, blank=True)
  image = models.ImageField(upload_to="blog")
  created_at = models.DateTimeField(auto_now_add=True)
  updated_at = models.DateTimeField(auto_now=True)

  def __str__(self):
    return self.title
  
  #overriding the save method
  def save(self, *args, **kwargs):
    self.slug = helpers.generate_slug(self.title)
    super(BlogModel, self).save(*args,**kwargs)
  