Beispiel #1
0
    def save(self, *args, **kwargs):
        """
        Override default save

        it will add the slug field using slugify.
        """
        if not self.event_slug:
            self.event_slug = get_unique_slug(self, 'name', 'slug')
        super().save(*args, **kwargs)
Beispiel #2
0
    def save(self, *args, **kwargs):
        """
        Override default save

        it will add the slug field using slugify.
        """
        if not self.event_slug:
            self.event_slug = get_unique_slug(self, 'name', 'slug')
        super().save(*args, **kwargs)
def fill_event_tags(apps, schema_editor):
    """Replace the old 'slug' field with a EventTag"""
    Event = apps.get_model('manager', 'Event')
    EventTag = apps.get_model('manager', 'EventTag')
    qs = Event.objects.filter(tags=None)
    for event in qs:
        event_tag, created = EventTag.objects.get_or_create(
            name=event.slug, defaults={"message": event.abstract})
        # run save to force slug creation.
        if not event_tag.slug:
            event_tag.slug = get_unique_slug(event_tag, 'name', 'slug')
            event_tag.save()
        event.tags.add(event_tag)
        event.save()
def fill_event_tags(apps, schema_editor):
    """Replace the old 'slug' field with a EventTag"""
    Event = apps.get_model('manager', 'Event')
    EventTag = apps.get_model('manager', 'EventTag')
    qs = Event.objects.filter(tags=None)
    for event in qs:
        event_tag, created = EventTag.objects.get_or_create(
            name=event.slug, defaults={"message": event.abstract})
        # run save to force slug creation.
        if not event_tag.slug:
            event_tag.slug = get_unique_slug(event_tag, 'name', 'slug')
            event_tag.save()
        event.tags.add(event_tag)
        event.save()
Beispiel #5
0
def set_slug_defaults(apps, schema_editor):
    Event = apps.get_model('manager', 'Event')
    qs = Event.objects.filter(event_slug=None)
    for event in qs:
        event.event_slug = get_unique_slug(event, 'slug', 'event_slug')
        event.save()