{{{
from django.db import models
from django.utils import timezone
from markdownx.models import MarkdownxField
from .utils import markdownify
from django.contrib.auth.models import User
from django.dispatch import receiver
from django.utils.text import slugify
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Blog(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True,
allow_unicode=False)
date = models.DateTimeField(auto_now_add=True)
description = MarkdownxField()
date_updated = models.DateTimeField(auto_now=True)
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
status = models.IntegerField(choices=STATUS, default=0)
class Meta:
ordering = ['-date']
def __str__(self):
return self.title
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super().save(*args, **kwargs)
def formatted_markdown(self):
return markdownify(self.description)
}}}
When model is saved, slug field is just empty.
I've checked if this code is working with "python-slugify" package, and it
works, creating a valid slug, so issue is definitely in Django slugify
function.
--
Ticket URL: <https://code.djangoproject.com/ticket/33472>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => worksforme
Comment:
It works for me, I cannot reproduce your issue with described models.
--
Ticket URL: <https://code.djangoproject.com/ticket/33472#comment:1>