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

Detect default api_configs.api_url #10

Closed
jayvdb opened this issue Apr 8, 2022 · 6 comments
Closed

Detect default api_configs.api_url #10

jayvdb opened this issue Apr 8, 2022 · 6 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Apr 8, 2022

Currently it is mandatory to have the following on each model:

    @classmethod
    def exposed_api(cls, *args, **kwargs):
        api_configs = {
            "api_url": 'my-model-api',
        }
        return api_configs

While most production sites will want to customise the urls, it is possible to derive a sensible default from the model class name, making it possible to add models to the API by only adding the mixin. Much faster. And even in production sites, there will be some parts of the API for which the default model name is an acceptable URI name, especially for smaller models.

@iashraful
Copy link
Owner

Do you really need API for every model? So, exposed_api is mandatory to enabled the API for the specific model. I guess I understand what did you say. If not please clarify me a little bit more.

@jayvdb
Copy link
Contributor Author

jayvdb commented Apr 20, 2022

If I dont want the model in the API, I wouldnt use the Mixin.

@iashraful
Copy link
Owner

Yes. If you don't want an API for a model don't use the mixin.

@jayvdb
Copy link
Contributor Author

jayvdb commented Apr 20, 2022

This issue is about when I have used the Mixin, I have already decided that I do want the model in the API, so the Mixin can automatically use sensible defaults without any mandatory exposed_api . Thus making it much easier for people to adopt fast-drf.

@iashraful iashraful reopened this Apr 20, 2022
@iashraful
Copy link
Owner

I got your point. That would be nice I think. I hope I'll do it soon.

iashraful added a commit that referenced this issue Apr 20, 2022
#10 Added support for detect api url automatically.
@iashraful
Copy link
Owner

The updated version is available on the Pypi: https://pypi.org/project/fast-drf/2.2.10/

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

2 participants