Last active
July 7, 2020 20:38
-
-
Save walison17/a37e3862b5ab8d3ca4906c780fe560e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BancoImoveisFilterView(FilterView): | |
model = Imovel | |
filterset_class = ImovelFilter | |
template_name = "imovel/imovel/banco_de_imoveis.html" | |
def get_queryset(self): | |
return ( | |
Imovel | |
.objects | |
.select_related( | |
"municipio", | |
"municipio__estado", | |
"tipo_uso", | |
"classe", | |
"esgoto_sanitario", | |
"energia_eletrica", | |
"area_insercao", | |
"orientacao_solar" | |
) | |
.prefetch_related("abastecimento_agua") | |
.all() | |
) | |
def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | |
helper = FormHelper() | |
helper.layout = Layout( | |
Row( | |
Column('status', css_class='select2 form-group col-md-3 mb-0'), | |
Column('indicacao_familia', css_class='select2 form-group col-md-3 mb-0'), | |
Column('vistoriado', css_class='select2 form-group col-md-3 mb-0'), | |
Column('tecnico_responsavel', css_class='select2 form-group col-md-3 mb-0'), | |
Column('responsavel_imovel', css_class='select2 form-group col-md-3 mb-0'), | |
Column('tipo_uso', css_class='select2 form-group col-md-3 mb-0'), | |
Column('municipio', css_class='select2 form-group col-md-3 mb-0'), | |
Column('area_insercao', css_class='select2 form-group col-md-3 mb-0'), | |
Column('classe', css_class='select2 form-group col-md-3 mb-0'), | |
css_class='form-row' | |
), | |
) | |
context["form_helper"] = helper | |
return context | |
# uso no template: {% crispy filter.form form_helper %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment