Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

title = [Invalid_Name] #1517

Open
Bastilla123 opened this issue Jul 14, 2022 · 0 comments
Open

title = [Invalid_Name] #1517

Bastilla123 opened this issue Jul 14, 2022 · 0 comments

Comments

@Bastilla123
Copy link

Hello,

my Filter:

class ProductFilter(django_filters.FilterSet):
class Meta:
model = StockRecord
fields = ['price']

    filter_overrides = {
       models.DecimalField: {
           'filter_class': django_filters.NumericRangeFilter,

     },

    }

i extend Productfilter with this defs:

def get_form_class(self):
    """
    Returns a django Form suitable of validating the filterset data.

    This method should be overridden if the form class needs to be
    customized relative to the filterset instance.
    """

    from collections import OrderedDict
    fields = OrderedDict([
        (name, filter_.field)
        for name, filter_ in self.filters.items()])
    **print("Output get_form_class fields " + str(fields))**
    return type(str('%sForm' % self.__class__.__name__),
                (self._meta.form,), fields)

@property
def form(self):
    if not hasattr(self, '_form'):
        Form = self.get_form_class()


        if self.is_bound:
            self._form = Form(self.data, prefix=self.form_prefix)
        else:
            self._form = Form(prefix=self.form_prefix)
        **print("Output def form " + str(self._form))**
        exit
    return self._form

As you see i insert normal defs only i have insert 2 print.

First print from def get_form_class(self): shows me

Output get_form_class fields OrderedDict([('price', <django_filters.fields.RangeField object at 0x7f7402336a00>)])

This is what i expect. 'price' is fieldname... Wunderfull

Next print:

Output def form [invalid name]:

You can see when form is create now label have name [invalid name]

Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant