我希望Django Orm从dB表中找到当前日期和日期时间字段之间的天数差异

时间:2018-09-01 04:56:51

标签: python django django-models orm

我的SQL查询如下所示。 我要在以下查询中使用Django orm。

"/home/erikas/myfile.txt" would become "/home/erikas/myfile-generated.txt"
"/home/erikas/myfile" would become "/home/erikas/myfile-generated"
"/my.directory/my.super.file.txt" would become "/my.directory/my.super.file-generated.txt"

Django模型:

editCalender

注意:Parse.initialize("X", "X"); Parse.serverURL = "X"; function editCalendar() { var Calendar = Parse.Object.extend("Calendar"); var query = new Parse.Query(Calendar); query.find({ success: function(results) { alert("Successfully retrieved " + results.length + " Data."); var calendarEventSelect = document.getElementById('calendar-event-select'); for (var i = 0; i < results.length; i++) { console.log(results[i]); OnlyRes = results[i]; countt = results[i]._objCount; chooseCalendarRaceName = results[i].attributes.raceName; raceNumber = results[i].attributes.raceNumber; raceName = results[i].attributes.raceName; stateCalendar = results[i].attributes.state; distanceCalendar = results[i].attributes.distance; raceLocationCalender = results[i].attributes.raceLocation; timeCalendar = results[i].attributes.time; htmlcalendarEventOption = `<option id5=${countt} id4="${timeCalendar}" id3="${raceLocationCalender}" id2="${distanceCalendar}" id1="${stateCalendar}" id="${raceName}" value="${raceNumber}">${chooseCalendarRaceName}</option>`; calendarEventSelect.innerHTML = htmlcalendarEventOption + calendarEventSelect.innerHTML; if (countt == 4) { results[i].set("raceName", "SSS TWO"); results[i].save(); } // i want this if statement to run when button is clicked. } }, error: function(error) { alert("Error: " + error.code + " " + error.message); } }); }; var updatebtnn = Y.one('#edit-calendar-btn'); updatebtnn.on('click', function(e) { if (countt == 4) { results[i].set("raceName", "SSS TWO"); results[i].save(); } });

0 个答案:

没有答案