from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from datetime import datetime, date
from ckeditor.fields import RichTextField

# Create your models here.


class Category(models.Model):
    name = models.CharField(max_length=255)
    def __str__(self):
        return self.name
    def get_absolute_url(self):
        return reverse('blog')

choices = Category.objects.all().values_list('name','name')


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default='Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk' : self.pk})

a8a5bf4b5a78953063782baa41b3e8c849c885ae
<mask token>


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


<mask token>


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default=
        'Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk': self.pk})

<mask token>


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

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('blog')


<mask token>


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default=
        'Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk': self.pk})

<mask token>


class Category(models.Model):
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('blog')


choices = Category.objects.all().values_list('name', 'name')


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default=
        'Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk': self.pk})

from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from datetime import datetime, date
from ckeditor.fields import RichTextField


class Category(models.Model):
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('blog')


choices = Category.objects.all().values_list('name', 'name')


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default=
        'Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk': self.pk})

from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from datetime import datetime, date
from ckeditor.fields import RichTextField

# Create your models here.


class Category(models.Model):
    name = models.CharField(max_length=255)
    def __str__(self):
        return self.name
    def get_absolute_url(self):
        return reverse('blog')

choices = Category.objects.all().values_list('name','name')


class Post(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    body = RichTextField()
    thumbnail = models.ImageField(upload_to='media/blogs/%Y/%m/')
    category = models.CharField(choices=choices, max_length=255, default='Uncategorised')
    posted_date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        return reverse('blog-details', kwargs={'pk' : self.pk})
