mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 21:27:49 +02:00
Extend functionalities
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from django.db import models
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from dcc.utils import get_image_preview
|
||||
from dcc.utils import get_image_preview, slugify
|
||||
|
||||
|
||||
class Manufacturer(models.Model):
|
||||
@@ -67,3 +68,16 @@ class Decoder(models.Model):
|
||||
def image_thumbnail(self):
|
||||
return get_image_preview(self.image.url)
|
||||
image_thumbnail.short_description = "Preview"
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
slug = models.CharField(max_length=128, unique=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@receiver(models.signals.pre_save, sender=Tag)
|
||||
def tag_pre_save(sender, instance, **kwargs):
|
||||
instance.slug = slugify(instance.name)
|
||||
|
Reference in New Issue
Block a user