how are you? first of all sorry for my bad english.
I have a problem with my server in DigitalOcean. i have the server running in Django with postgres and in local i use SQLite.
In both i use Python 3.4 - in local windows and python 3.4.3 in DO Ubuntu with python 3.4.0
Have a problem filtering a query.
this is the model
# Create your models here.
class WorkOrder(models.Model):
fk_client = models.ForeignKey(Client, verbose_name='Cliente')
fk_store = models.ForeignKey(Store, verbose_name='Local')
store_internal_order = models.CharField(verbose_name='Orden Interna',
max_length=10,
null=True,
blank=True)
sector = models.IntegerField(verbose_name='Sector',
choices=SECTOR_CHOICES,
default=1)
article = models.CharField(verbose_name='Dispositivo', max_length=20)
serial = models.CharField(verbose_name='Serial', max_length=25)
work = models.CharField(verbose_name='Trabajo', max_length=40)
article_details = models.CharField(verbose_name='Detalles Artículo',
max_length=255, blank=True)
cash_advance = models.DecimalField(verbose_name='Seña', max_digits=6,
decimal_places=2,
default=0)
initial_price = models.DecimalField(verbose_name='Precio', max_digits=6,
decimal_places=2,
default=0)
service_cost = models.DecimalField(verbose_name='Costo', max_digits=6,
decimal_places=2,
default=0)
randpassw = models.CharField(default='12345', max_length=5, blank=True,
null=True)
warranty = models.PositiveSmallIntegerField(verbose_name='Garantía',
default=0,
blank=True,
null=True)
last_status = models.IntegerField(verbose_name='Estado',
choices=STATUS_CHOICES,
default=1)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
def __str__(self):
return str(self.id)
this is the view
def index(request):
if not request.user.is_authenticated():
return redirect('auth_login')
title = "Lista de Ordenes"
# Creamos el query para tomar las ordenes
queryset = WorkOrder.objects.all()
queryset = queryset.exclude(last_status=20)
# Tomamos el filtro de sector
sector_filter = request.GET.get('sector')
# Tomamos filtro de ENTREGADAS
# delivered = reqeust.GET.get('delivered')
context = {
'title': title,
}
if not request.user.is_staff:
user_store = request.user.userprofile.fk_store
# Añadimos otro filtro al queryset para tomar solo las del local
# correspondiente al usuario
queryset = queryset.filter(fk_store=user_store)
store = Store.objects.get(name=user_store)
context.update({'store': store})
# Si hay un filtro de sector volvemos a filtrar el queryset
if sector_filter:
queryset = queryset.filter(sector=sector_filter)
context.update({'queryset': queryset})
paginator = Paginator(queryset, 7) # Show 5 orders per page
page = request.GET.get('page')
try:
orders = paginator.page(page)
except PageNotAnInteger:
# If the page is not an integer, deliver first page
orders = paginator.page(1)
except EmptyPage:
orders = paginator.page(paginator.num_pages)
context.update({'orders': orders})
return render(request, "workorders/index.html", context)
Well here is my problem i have to filter all the work orders that have in the Last Status the Status "20" (int)
In local work perfect! i can see all the orders except the orders with last status 20. But in production in DigitalOcean VPS with gunicorn running. The query only show the orders with last status 1 and is filtering all the other orders.
i try first with this queryset queryset = WorkOrder.objects.filter(~Q(last_status=20))
and after that i change for the queryset that you can see in my view. Both work fine in local but not in production.
any idea?
Thanks very much for your help!
Aucun commentaire:
Enregistrer un commentaire