Consuming own API in Django Web Application

I would like to know, if is it a right design architecture to consume own API for Django Web Application development?

Lets say,

I have an DRF API for CRUD functions and can I use the same API to build a CRUD web application in Django?


If you’re saying you’d like your Django app to issue requests to an API view, it could. But I would do it as an internal function call and not as an HTTP request being issued to the corresponding URL. (That would seem to me to be uselessly suboptimal.)

I agree with Ken. Is there a reason why you’re looking to architecture your application this way?

I agree to this, and somehow not convinced that this is still DRY.

I have created a module and linked all the request methods to the corresponding endpoints of API (through requests) and then call these services in my Django as required. Now all my endpoints are served through views (return json) and again in my Django web application, I have similar views… Am i missing something?

Yes, building a SaaS based application, where myself is a service provider, and subscribers can become service providers themselves too through the API.

Yes, the overhead of a bunch of excess HTTP requests.

Calling a function directly is going to be far more performant and scalable than issuing an HTTP request that gets routed through to that same function.

Both your endpoints and your Django web app should be calling those functions in services and not requesting them through a web-based API.

Quite honestly, it seems exceedingly silly and wasteful to even think about doing it that way. You gain zero benefits from doing so, at a tremendous expense.

Let me change to this. Thanks