0👍
✅
I have updated to South 0.7.6 and used solution from the South documentation. Simply added to_python()
and get_prep_value()
methods to leave slug
field as is.
class AutoSlugField(models.CharField):
def pre_save(self, blog, *args, **kwargs):
return slugify(unicode(blog))
def to_python(self, value):
return value
def get_prep_value(self, value):
return value
1👍
South does nothing but just add column to your table and django has no role to play in it. So when you run migration, django model save method is not called hence no pre-save method gets called. South works on database only, i.e., you can provide attributes such as default value, nullable etc. which can be set at db level. To add slug to existing records in db, create util function which would slugify your field or write a data migration.
- [Answer]-Django forms: MultipleChoiceField Error too many values to unpack
- [Answer]-Type object 'Espece' has no attribute 'esp_id'
- [Answer]-Pagination with Jquery or Django?
- [Answer]-Django: is it possible to exclude ForeignKey in derived model
- [Answer]-Django: getting NoReverseMatch at / error
Source:stackexchange.com