Note that there are some explanatory texts on larger screens.

plurals
  1. PODerived django class based view and context data
    primarykey
    data
    text
    <p>I have a problem. I have at least three class- and one context-data titre who is the title of the page.</p> <p>One generic class for form:</p> <pre><code>class Myformview(generic.FormView): form_class = None template_name = None titre=None @method_decorator(login_required) def dispatch(self, *args, **kwargs): """on a besoin pour le method decorator""" return super(Myformview, self).dispatch(*args, **kwargs) def get_context_data(self, *args, **kwargs): context= super(Myformview, self).get_context_data(*args, **kwargs) if self.titre is not None: context.update({'titre':self.titre}) return context </code></pre> <p>As I have different way to export a base class to export data:</p> <pre><code>class ExportViewBase(FormView): template_name = 'param_export.djhtm' # nom du template model_initial = None # model d'ou on tire les dates initiales extension_file = None nomfich = None debug = False form_class = None def export(self, query): """ fonction principale mais abstraite """ raise django_exceptions.ImproperlyConfigured( "attention, il doit y avoir une methode qui extrait effectivement") def get_initial(self): """gestion des donnees initiales""" if self.model_initial is None: raise django_exceptions.ImproperlyConfigured("un modele d'ou on tire les dates initiales doit etre defini") date_min = self.model_initial.objects.aggregate( element=models_agg.Min('date'))['element'] date_max = self.model_initial.objects.aggregate( element=models_agg.Max('date'))['element'] return {'date_min': date_min, 'date_max': date_max} @method_decorator(login_required) def dispatch(self, *args, **kwargs): """on a besoin pour le method decorator""" return super(ExportViewBase, self).dispatch(*args, **kwargs) def form_valid(self, form): """si le form est valid""" reponse = self.export(query=form.query) if self.nomfich is None: raise django_exceptions.ImproperlyConfigured('nomfich undefined') if self.extension_file is None: raise django_exceptions.ImproperlyConfigured('extension_file undefined') reponse["Cache-Control"] = "no-cache, must-revalidate" reponse['Pragma'] = "public" reponse["Content-Disposition"] = "attachment; filename=%s_%s.%s" % (self.nomfich, time.strftime("%d_%m_%Y-%H_%M_%S",time.localtime()), self.extension_file) return reponse </code></pre> <p>and the effective class to export:</p> <pre><code>class Export_view_sql(export_base.ExportViewBase): extension_file = "sql" debug = True nomfich = "export_full" model_initial=models.Ope form_class = export_base.Exportform_ope titre="export sql" def export(self, query): pass#code to export </code></pre> <p>It does not, however, update titre as expected. What is the reason for this?</p> <p>If i set titre in <code>ExportViewBase</code>, it works but in <code>Export_view_sql</code> it does not. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload