Spaces:
Running
Running
Download api/models/content.py from Dayozoe/harvestconnect-api: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/models/content.py
- Command line
-
hf download hf://spaces/Dayozoe/harvestconnect-api/api/models/content.py
-
curl -L -o content.py https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/models/content.py
1.35 kB
| from django.db import models | |
| from django.contrib.auth.models import User | |
| from django.utils.text import slugify | |
| class BlogPost(models.Model): | |
| """Blog posts for community hub""" | |
| CATEGORY_CHOICES = [ | |
| ('all-stories', 'All Stories'), | |
| ('farming', 'Farming'), | |
| ('artisanship', 'Artisanship'), | |
| ('faith', 'Faith'), | |
| ('sustainability', 'Sustainability'), | |
| ('market-updates', 'Market Updates'), | |
| ] | |
| title = models.CharField(max_length=255) | |
| slug = models.SlugField(unique=True) | |
| excerpt = models.TextField(max_length=500) | |
| content = models.TextField() | |
| category = models.CharField(max_length=50, choices=CATEGORY_CHOICES) | |
| author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts') | |
| featured = models.BooleanField(default=False) | |
| image = models.ImageField(upload_to='blog/', blank=True, null=True) | |
| views = models.IntegerField(default=0) | |
| created_at = models.DateTimeField(auto_now_add=True) | |
| updated_at = models.DateTimeField(auto_now=True) | |
| published = models.BooleanField(default=True) | |
| def save(self, *args, **kwargs): | |
| if not self.slug: | |
| self.slug = slugify(self.title) | |
| super().save(*args, **kwargs) | |
| def __str__(self): | |
| return self.title | |
| class Meta: | |
| ordering = ['-created_at'] | |