Loading and Using an ML model in Django

It is definitely recommended to load your ML models in apps.py. When the application runs here, the trained model is loaded only one time. Otherwise, the trained model is loaded whenever an endpoint is called, and the response time will therefore be slower. Let’s assume that your trained model is ready to predict stock prices … Read more

Fix Circular Import in Django

In some rare cases, you may import a file that imports the file you are importing from. This may seem a bit recursive, and it is. In Python, this is called a circular import error. The best way to recognize a circular import gone wrong is to look at your results. You’ll get an ImportError … Read more

Django rest framework, use different serializers in the same ModelViewSet

Django rest framework allows the creation and the use of different serializers (objects allowing complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON , XML or other content types) within the same ModelViewSet. For instance, if you would like to use PutHeroSerializer … Read more

Angular Dynamic Table with Django API

This component allows you to perform real-time HTTP requests to a Django API (backend), search, and filter data easily and simply. Requirements Let’s assume that you have a Django server up and running on the port 8000. In this example, I’ve created and configured a Django app called patient (backend), so the URL to this … Read more