代码之家  ›  专栏  ›  技术社区  ›  Pavan Kumar T S

django order_不在服务器上运行,但在本地计算机上运行良好

  •  0
  • Pavan Kumar T S  · 技术社区  · 7 年前

    class Leave(models.Model):
     from_date = models.DateField(verbose_name='From')
     to_date = models.DateField(verbose_name='To')
     leave_type = models.ForeignKey(TotalLeave,verbose_name='Type',null=True)
     message = models.CharField(max_length=1000,verbose_name='Message to your Manager regarding your leave',null=True)
     created_by = models.ForeignKey(User,related_name='created_user',null=True)
     created_datetime = models.DateTimeField(null=True,blank=True)
     last_modified_by = models.ForeignKey('auth.user',null=True)
     last_modified_date = models.DateTimeField(default=datetime.now,null=True)
     emp = models.ForeignKey('Employee',null=True)
     approval_status = models.BooleanField(default=False,verbose_name='Leaves approved or not ?')
    

    查看:

    @login_required
    def all_requests(request):
        inner_qs = Employee.objects.filter(email=request.user.email)
        entries = Employee.objects.filter(reporting_manager__in=inner_qs)
        if (request.user.is_staff):
            if request.method == 'POST':
                month = request.POST.get('month')
                leaves = Leave.objects.filter(from_date__month=month).order_by('approval_status')
            else:
                leaves = Leave.objects.all().order_by('approval_status')
        else:
            leaves = Leave.objects.filter(emp__in=entries).order_by('approval_status')
        from django.db.models.functions import TruncMonth
        months = Leave.objects.annotate(month=TruncMonth('from_date')).values('month').annotate(c=Count('id')).values('month', 'c')
    

    2 回复  |  直到 7 年前
        1
  •  1
  •   Pavan Kumar T S    7 年前

    原来Apache wsgi没有收到我的新请求,所以我触摸了wsgi文件,它工作了。谢谢你的帮助

        2
  •  0
  •   David Buck RevolverRakk    3 年前

    触摸项目中的wsgi文件

    ssh root@webserver.local touch'var/www/django_site/app/wsgi.py'
    

    它只要求是/否-->点击yes并输入您的密码,然后就可以开始了

    例如:

    ssh root@mysite.com touch ..