Exemple #1
0
 def __init__(self, *args, **kwargs):
     super(DashboardWidgetForm, self).__init__(*args, **kwargs)
     
     if 'instance' in kwargs:
         self.fields['datetime_field'] = forms.ChoiceField(choices=(), widget=forms.Select)
         instance = kwargs['instance']
         self.fields['datetime_field'].choices = get_datetime_fields(instance.model)
         self.fields['datetime_field'].default = instance.datetime_field
Exemple #2
0
def model_fields(request, model_name):
    fields = get_datetime_fields(model_name)
    return HttpResponse(json.dumps(fields), mimetype='application/json')