Slugify more uniquely. Closes #125.
parent
d464660495
commit
8d3f4a7a82
|
@ -3,6 +3,8 @@ from django.template.defaultfilters import slugify
|
||||||
from registration.signals import user_registered
|
from registration.signals import user_registered
|
||||||
from pygments.lexers import get_all_lexers
|
from pygments.lexers import get_all_lexers
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
def slugify_uniquely(value, model, slugfield="slug"):
|
def slugify_uniquely(value, model, slugfield="slug"):
|
||||||
suffix = 0
|
suffix = 0
|
||||||
|
@ -13,7 +15,7 @@ def slugify_uniquely(value, model, slugfield="slug"):
|
||||||
potential = "-".join([base, str(suffix)])
|
potential = "-".join([base, str(suffix)])
|
||||||
if not model.objects.filter(**{slugfield: potential}).count():
|
if not model.objects.filter(**{slugfield: potential}).count():
|
||||||
return potential
|
return potential
|
||||||
suffix += 1
|
suffix = str(uuid.uuid4()).split('-')[0]
|
||||||
|
|
||||||
def activate_user(user, request, **kwargs):
|
def activate_user(user, request, **kwargs):
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
|
|
6
urls.py
6
urls.py
|
@ -70,6 +70,6 @@ urlpatterns = patterns('',
|
||||||
url(r'^', include('snipts.urls')),
|
url(r'^', include('snipts.urls')),
|
||||||
)
|
)
|
||||||
|
|
||||||
if settings.DEBUG:
|
urlpatterns += patterns('',
|
||||||
urlpatterns = urlpatterns + static('/media/',
|
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/Users/Nick/Code/snipt/static'}),
|
||||||
document_root=os.path.join(settings.BASE_PATH, 'media'))
|
)
|
||||||
|
|
Loading…
Reference in New Issue