-
Notifications
You must be signed in to change notification settings - Fork 769
Port get_schema_fields from DRF #492
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
Port get_schema_fields from DRF #492
Conversation
| template = loader.get_template(self.template) | ||
| return compat.template_render(template, context) | ||
|
|
||
| def get_fields(self, view): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a Doc string: what's this for? Ta.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original blame points to core-api/schema generation, but I'm not familiar with that so I don't actually understand how this method is being used. @tomchristie?
Side note - I saw @kevin-brown's comment here and simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this is used by the schema generation to introspect what fields are required by a filter class. It's not formalized in the docs yet, so we should discuss prior to any 1.0 django-filter / 3.5 rest framework releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomchristie - could you take a look at 291717f? Does this seem correct? Thanks for the help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me.
| return compat.template_render(template, context) | ||
|
|
||
| def get_fields(self, view): | ||
| filter_class = self.get_fitler_class() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_fitler_class()
And this is why we test anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I promise I can spell.
1ea3226 to
291717f
Compare
|
@carltongibson. Anything else that needs to be done here? I'm considering holding off on a doc string until |
|
Okay, these will become public API in 3.5 onwards, as |
|
Awesome. Thanks Tom. |
291717f to
0b1ec05
Compare
86305ea to
bc35978
Compare
|
Hi @carltongibson - this should be ready for review. btw, there is technically a flaw with the implementation, but I don't think it's worth fixing. Given the following, class UserFilter(FilterSet):
username = filters.CharFilter()
last_login__between = filters.DateTimeFromToRangeFilter(name='last_login', lookup_expr='range')
class Meta:
model = User
Realistically, this is only an issue for
My thoughts are to either:
|
|
OK. This is great. I'll merge this and push a 0.15.3 this morning. 👍 @tomchristie I think we're good from this side for DRF 3.5. |
|
Great stuff! |
No description provided.