1 # -*- coding: utf-8 -*-
2 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.db import models
7 class SlugNullField(models.SlugField):
8 description = "SlugField that stores NULL instead of blank value."
10 def to_python(self, value, **kwargs):
11 value = super(SlugNullField, self).to_python(value, **kwargs)
12 return value if value is not None else u""
14 def get_prep_value(self, value, **kwargs):
15 value = super(SlugNullField, self).get_prep_value(value, **kwargs)
21 from south.modelsinspector import add_introspection_rules
25 add_introspection_rules([], ["^migdal\.fields\.SlugNullField"])