slug is only changed if title changes and it has not been set before.

This commit is contained in:
2021-04-21 13:01:45 +00:00
parent 1b5c71388d
commit 5fcb2495e7
2 changed files with 8 additions and 4 deletions

View File

@@ -146,11 +146,13 @@ def slug_calc(request):
if request.method == "GET":
get = request.GET.copy()
title = get["title"]
slug_str = get["slug"]
datetime_now = timezone.now()
date_str = datetime_now.strftime("%Y-%m-%d")
if not slug_str:
datetime_now = timezone.now()
date_str = datetime_now.strftime("%Y-%m-%d")
slug_str = slugify(date_str) + "-" + slugify(title)
slug_str = slugify(date_str) + "-" + slugify(title)
return HttpResponse(slug_str)