Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在django使用keith wood倒数计时器进行实时倒数_Javascript_Jquery_Html_Django_Jquery Countdown - Fatal编程技术网

Javascript 在django使用keith wood倒数计时器进行实时倒数

Javascript 在django使用keith wood倒数计时器进行实时倒数,javascript,jquery,html,django,jquery-countdown,Javascript,Jquery,Html,Django,Jquery Countdown,大家好,我正在使用keith wood倒计时,如何在用户登录后将默认倒计时设置为(14天)倒计时,即使用户注销或离开页面,倒计时仍然是多余的 <div id="defaultCountdown"></div> <script> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26); $('#de

大家好,我正在使用keith wood倒计时,如何在用户登录后将默认倒计时设置为(14天)倒计时,即使用户注销或离开页面,倒计时仍然是多余的

<div id="defaultCountdown"></div>
<script>
$(function () {
    var austDay = new Date();
    austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26);
    $('#defaultCountdown').countdown({until: austDay});
    $('#year').text(austDay.getFullYear());
});
</script>

伙计们,请帮帮我,

所以你想让每个用户的14天倒计时从用户登录之日算起?是的,Rory McCrossana先生仍然会继续,即使用户离开页面或登录,只需在
用户
模型中保存用户登录的日期时间(或到期时间,即登录时间+14天)。然后,您可以始终计算距离倒计时结束还有多少时间,并将其显示或作为可在javascript中使用的模板中的变量传递。请注意,您的登录方法(将
request.POST['password']
m.password
进行比较)是非常错误的。这意味着您在数据库中将密码保存为纯文本!永远不要那样做。
def profile(request):
    if request.method != 'POST':
        raise Http404('Only POSTs are allowed')
    try:
        m = User.objects.get(username=request.POST['username'])
        if m.password == request.POST['password']:
            aa = request.POST['username']
            request.session['member_id'] = m.id
            print(m.id)
            return render(request, 'profile.html')

    except User.DoesNotExist:
        messages.Warning(request, 'Incorrect Username or Password.')
    return render (request, "login.html")