These are chat archives for django/django

Jul 2018
Jul 13 2018 02:33
I 'm using semantic UI modal
import json  
import datetime
import ast
from django.core.serializers.json import DjangoJSONEncoder
from decimal import *
from django.shortcuts import get_object_or_404
import dateutil.parser 
from django.core import serializers
from django.utils.dateparse import parse_date
import os ,PIL ,time ,hashlib, string    
from django.core.paginator import Paginator
from import default_storage 
from django.conf import settings
from django.shortcuts import render
from django.db import models
from django.views.generic import FormView ,ListView,CreateView,UpdateView,FormView,DetailView,View
from django.contrib.messages.views import SuccessMessageMixin
from django.http import HttpResponseRedirect,HttpResponse,JsonResponse
from ..operacoes.baseos import CORES_STATUS,OSServico ,ImagesOS
from ..views import BasicoNavegacaoView
from django.template import Template
from django.contrib.contenttypes.models import ContentType
from django.views import View
from django.template.response import TemplateResponse
from ..cidades.cidade import Cidade
from ..pessoa.pessoa import Pessoa

from ..empresa.empresa import Empresa
from ..produto.produto import Produto
from ..empresa.forms import EmpresaForm
from cadastros.area_tipo.models import Tipo, Area
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import generics
from .serializer import OsSerializer
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import mixins
from rest_framework import generics
from .forms import  LoteOSForm
from .models import ProcessoLote
from rest_framework import viewsets, permissions, response,pagination ,generics
from rest_framework.decorators import api_view
from rest_framework import status
from financeiro.models import STATUS_FIN,retorna_status_fin
from django.db.models import Sum
from rest_framework.authentication import SessionAuthentication, BasicAuthentication ,TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework import authentication, permissions

class LotesCreate(SuccessMessageMixin,BasicoNavegacaoView,CreateView):
    model = ProcessoLote
    form_class = LoteOSForm
    template_name = 'lotes/form-lotes.html'
    success_message = "Lote criado sucesso"

    def get_form_kwargs(self):
        kwargs = super(LotesCreate, self).get_form_kwargs()
        lista_os = self.request.GET.get('os')
        if lista_os !=None:
            lista = OSServico.objects.filter(pk__in=ast.literal_eval(lista_os))
            initial = {'os_item':lista.values_list('id', 'nro_assis'),'total_lote':OSServico.os_filtros.retorna_total_os(queryset= lista)}
            kwargs.update({'initial': initial})
        return kwargsa
hi guys how i can set initial queryset in get_form_kwargs?
im my model form area os_item = forms.ModelMultipleChoiceField(label="OS",queryset = OSServico.objects.filter(pk=-1), required=True)
Curtis Maloney
Jul 13 2018 04:39
@estherjsuh Lacey Williams Henschel did a great blog post on dockerising django, and a talk at this years DjangoCon EU
Miracle Ayodele
Jul 13 2018 08:36
@chumaumenze and @funkybob thanks for your input on sending fk field over api, i noticed for every pk field in your model, you need to define the fk also in your tastypie ModelResource, it's now working cool
Curtis Maloney
Jul 13 2018 09:48
tastypie? wow... that's still a thing?
Miracle Ayodele
Jul 13 2018 09:57
what do you mean by that's still a thing?, is it out of date? @funkybob
Curtis Maloney
Jul 13 2018 10:05
it was dead for a long time... and by the time it was resurrected, Django REST Framework had well and truely secured the market...
(which was annoying... meant my django-nap lib didn't get much of an audience)
Miracle Ayodele
Jul 13 2018 11:17
oh i see, i hope they stay long this time around :smirk:
Elijah Rippeth
Jul 13 2018 11:47
Hi y'all. Is there a way to execute admin-commands from the admin site? I found an unmaintained repo on github that claims it could help, but it's quite dead.
Jul 13 2018 22:41