slug is only changed if title changes and it has not been set before.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
window.addEventListener("load", function() {
|
window.addEventListener("load", function() {
|
||||||
(function($) {
|
(function($) {
|
||||||
|
var slug = $("input#id_slug").val();
|
||||||
|
|
||||||
$("input#id_title").on('input', function() {
|
$("input#id_title").on('input', function() {
|
||||||
var title = $("input#id_title").val();
|
var title = $("input#id_title").val();
|
||||||
|
|
||||||
@@ -10,7 +12,7 @@ window.addEventListener("load", function() {
|
|||||||
getUrl = window.location
|
getUrl = window.location
|
||||||
baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[0];
|
baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[0];
|
||||||
|
|
||||||
$.ajax({type:'GET', url: baseUrl + 'posts/func/slug_calc', data:{'title': title }, complete:complete});
|
$.ajax({type:'GET', url: baseUrl + 'posts/func/slug_calc', data:{'title': title, 'slug': slug }, complete:complete});
|
||||||
});
|
});
|
||||||
})(django.jQuery);
|
})(django.jQuery);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -146,7 +146,9 @@ def slug_calc(request):
|
|||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
get = request.GET.copy()
|
get = request.GET.copy()
|
||||||
title = get["title"]
|
title = get["title"]
|
||||||
|
slug_str = get["slug"]
|
||||||
|
|
||||||
|
if not slug_str:
|
||||||
datetime_now = timezone.now()
|
datetime_now = timezone.now()
|
||||||
date_str = datetime_now.strftime("%Y-%m-%d")
|
date_str = datetime_now.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user