我有一个请求模型
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')
我正在尝试基于审批状态的订单离开这在localhost上工作正常但是如果我拉服务器它的工作在某种意义上,order_by完全没有在服务器上工作我在服务器和本地机器上使用MYSQL
答案 0 :(得分:0)
原来Apache wsgi没有得到我的新拉动所以我触及了wsgi文件并且它工作了感谢帮助
答案 1 :(得分:0)
触摸项目中的 wsgi 文件
在服务器
ssh root@webserver.local touch'var/www/django_site/app/wsgi.py'
它只是要求是/否 --> 点击是并输入你的密码,然后你就可以走了
例如:
ssh root@mysite.com touch ..