concentricsky / django-tastypie-swagger

An adapter to use swagger-ui with django-tastypie.
Other
132 stars 144 forks source link

Getting filters causes AttributeError #101

Closed paul-wolf closed 9 years ago

paul-wolf commented 9 years ago

Django: 1.7.4 Tastypie: 0.12.1 django-tastypie-swagger: 0.1.4

In mapping.py, Line 191: self.schema['filtering'] is expected to be a dict, but it's a tuple.

    for name, field in self.schema['filtering'].items():
    AttributeError: 'tuple' object has no attribute 'items'

Source:

        if 'filtering' in self.schema and method.upper() == 'GET':
            for name, field in self.schema['filtering'].items():
                # Avoid infinite recursion for self referencing resource (issue #22)
                if not prefix.find('{0}__'.format(name)) >= 0:
                    # Integer value means this points to a related model
                    if field in [ALL, ALL_WITH_RELATIONS]:
johnraz commented 9 years ago

self.schema['filtering'] is extracted from your very own code, I suspect a trailing coma somewhere after you dict leading to a tuple...

paul-wolf commented 9 years ago

You are right. My fault. Apologies. It was a stray comma in the meta class after the filtering attribute that made it into a tuple.

Thanks for quick response anyway.

johnraz commented 9 years ago

No problem, glad I could help ;-)