- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Smooth profiling in Django
In this article, we are going to make a Django profiling. It will show a great deal of information like the total number of GET requests, database queries and many other reports for your website on a URL endpoint. It is great in production because you need to keep a check on many things when your site is in production.
It is a great resource if you have to deploy a real-world project.
Example
First of all, create a project and an app. Do some basic settings and set up the urls.
Now, install the djnago-silk package −
pip install django-silk
In settings.py, add the following lines −
MIDDLEWARE = [ ... 'silk.middleware.SilkyMiddleware', ... ] INSTALLED_APPS = [ ... 'silk' ]
We simply added it as app and a middleware and module as an app.
In project's url.py −
urlpatterns += [path('silk/', include('silk.urls', namespace='silk'))]
Here we defined the endpoint where we will see profiling.
Now run these commands −
python manage.py makemigrations python manage.py migrate
These commands are for creating silk migrations and to migrate them.
With that, everything is set and you can proceed to check the output.
Output
Go to http://127.0.0.1:8000/silk/
- Related Articles
- Criminal Profiling
- How to implement django-material in your Django project?
- Checking smooth sentences in JavaScript
- Form widget in Django
- Google Authentication in Django
- Exporting models data in Django
- Enabling GitHub OAuth in Django
- Implementing models reversion in Django
- Adding a DeleteView in Django
- What is middleware in django
- Django – Making a Django website more human-like using Humanizer
- Smooth Scrolling with Pure CSS
- Adding JSON field in Django models
- Importing data into models in Django
- QR code generating website in Django
