ivelum / djangoql

Advanced search language for Django
MIT License
1k stars 88 forks source link

Restrict fields #120

Closed MrMarble closed 2 months ago

MrMarble commented 2 months ago

Thanks for the work on djangoql, is amazing!

I'm wondering if there's any way to restrict which fields can be used with djangoql, we have some internal fields in the Models that are not intended to be used by the user, and djangoql allows to filter with them, but the main problem are suggestions and the message when you try to use a field that is not available, all those internal fields appear on the list.

I tried with the exclude option (docs) but that does not seem to work

stebunovd commented 2 months ago

Hi @MrMarble,

I guess the problem might be that you're referring to the django-filter docs and not the DjangoQL docs. Please try the example from the official docs and it should work.

Thanks,

Denis

MrMarble commented 2 months ago

@stebunovd Thanks! I'm working on the example you gave me. The exclude is only meant to be used with Models right? to exclude them from the query.

To exclude fields of a Model I need to use the get_fields method, but this seems to list all the wanted fields, so I need to list every field that I want to allow the search right?

MrMarble commented 2 months ago

I'll close the issue since I managed to filter out fields with the DjangoQL Schema