
Quick Contact
Python Tutorial
- What is Python?
- How to Install Python?
- Python Variables and Operators
- Python Loops
- Python Functions
- Python Files
- Python Errors and Exceptions
- Python Packages
- Python Classes and Objects
- Python Strings
- PostgreSQL Data Types
- Python Generators and Decorators
- Python Dictionary
- Python Date and Time
- Python List and Tuples
- Python Multithreading and Synchronization
- Python Modules
- What is Python bytecode?
- Python Regular Expressions
Python Panda Tutorial
- Python Pandas Tutorial
- Python Pandas Features
- Advantages and Disadvantages of Python Pandas
- Pandas Library In Python
- Pandas Series To Frame
- Python Dataframeaggregate and Assign
- Pandas Dataframe Describe
- Pandas Dataframe Mean
- Pandas Hist
- Pandas Dataframe Sum
- How to convert Pandas DataFrame to Numpy array
Python Selenium
- Selenium Basics
- Selenium with Python Introduction and Installation
- Navigating links using get method Selenium Python
- Locating Single Elements in Selenium Python
- Locating Multiple elements in Selenium Python
Python Flask Tutorial
Python Django
- How to Install Django and Set Up a Virtual Environment in 6 Steps
- Django MTV Architecture
- Django Models
- Django Views
- Django Templates
- Django Template Language
- Django Project Layout
- Django Admin Interface
- Django Database
- Django URLs and URLConf
- Django Redirects
- Django Cookies and Cookies Handling
- Django Caching
- Types of Caching in Django
- Django Sessions
- Django Forms Handling & Validation
- Django Exceptions & Error-handling
- Django Forms Validation
- Django Redirects
- Django Admin Interface
- Django Bootstrap
- Ajax in Django
- Django Migrations and Database Connectivity
- Django Web Hosting and IDE
- Django Admin Customization
- What is CRUD?
- Django ORM
- Django Request-Response Cycle
- Django ORM
- Making a basic_api with DRF
- Django Logging
- Django Applications
- Difference between Flask vs Django
- Difference between Django vs PHP
Numpy
- Numpy Introduction
- NumPy– Environment Setup
- NumPy - Data Types
- NumPy–Functions
- NumPy Histogram
- numPy.where
- numpy.sort
- NumPyfloor
- Matrix in NumPy
- NumPy Arrays
- NumPy Array Functions
- Matrix Multiplication in NumPy
- NumPy Matrix Transpose
- NumPy Array Append
- NumPy empty array
- NumPy Linear Algebra
- numpy.diff()
- numpy.unique()
- numpy.dot()
- numpy.mean()
- Numpy.argsort()
- numpy.pad()
- NumPyvstack
- NumPy sum
- NumPy Normal Distribution
- NumPylogspace()
- NumPy correlation
- Why we learn and use Numpy?
Tensorflow
- Introduction To Tensorflow
- INTRODUCTION TO DEEP LEARNING
- EXPLAIN NEURAL NETWORK?
- CONVOLUTIONAL AND RECURRENT NEURAL NETWORK
- INTRODUCTION TO TENSORFLOW
- INSTALLATION OF TENSORFLOW
- TENSORBOARD VISUALIZATION
- Linear regression in tensorflow
- Word Embedding
- Difference between CNN And RNN
- Explain Keras
- Program elements in tensorflow
- Recurrent Neural Network
- Tensorflow Object Detection
- EXPLAIN MULTILAYER PERCEPTRON
- GRADIENT DESCENT OPTIMIZATION
Interview Questions & Answers
Django Admin Customization
Django Admin is one of the most important tools of Django. It’s a full-fledged application with all the utilities a developer need. Django Admin’s task is to provide an interface to the admin of the web project. Django’s Docs clearly state that Django Admin is not made for frontend work.
Django Admin’s aim is to provide a user interface for performing CRUD operations on user models and other functionalities like authentication, user access levels, etc. These all are functions that make admin more productive.
Django Admin Customization
We will be customizing some parts of the Django Admin. This customization will provide us with a better representation of objects. To implement it in your project, make a new app in your Django project named products.
Command:
python manage.pystartapp products
Code:
fromdjango.db import models #Ducatindia class Product(models.Model): name = models.CharField(max_length = 200) description = models.TextField() mfg_date = models.DateTimeField(auto_now_add = True) def __str__(self): return self.name defshow_desc(self): returnself.description[:50]
Now, we need to migrate these changes to the database. For that, execute these commands in order.
python manage.py makemigrations
python manage.py migrate
We need to register these models on the Django Admin. To do this, edit the products/admin.py file. Paste this code after clearing the file.
Code:
fromdjango.contrib import admin from .models import Product # Register your models here. # Ducatindia admin.site.register(Product)
We will make a lot of changes to this panel.
-
Register/ Unregister models from admin
We can register models in admin easily. We have used the register method to register models in the admin. But, what to do for unregistering models?
A valid point of the argument is that you simply don’t register the model. Yes, that’s true. What if we want to remove default models like Groups, Users from admin? The answer is unregister method.
Let’s see how to unregister the model.
Open, products/admin.py file and paste this code in it.
Code:
fromdjango.contrib import admin fromdjango.contrib.auth.models import Group from .models import Product # Register your models here. # Ducatindia admin.site.register(Product) admin.site.unregister(Group)
Now, simply reload your server and open the admin panel. You will see that the Group model is not there.
-
Changing the title of Django Admin
There are so many parts that can be changed from the front-end perspective. Like you can change the title written in the top-left corner of the web-page. Django administration can be changed to anything you like.
Add this line in products/admin.py file.
Code:
admin.site.site_header = “DucatindiaDjango Tutorials”
-
ModelAdmin Class
The ModelAdmin class is a representation of user-defined models in the admin panel. It can be used to override various actions. There is a whole range of options opened with ModelAdmin Class.
We have to register the Admin Model alongside the model we want to change. Suppose, we want to exclude some fields to not be shown on the admin panel.
We can do that by simply adding these lines in products.admin.py file.
Code:
# ModelAdmin Class # Ducatindia classProductA(admin.ModelAdmin): exclude = ('description', )
-
Customizing List Display in Django Admin
You should add some products before we check out this one. Populate your database with 5-6 products. After you have added some products, open the products model from the admin panel. There you will see a list of Product objects. It only shows the names of the products like in the image.
There are many scenarios where one might want more information visible in the list view. We can see all the information in the database. Similarly, we can choose the fields we want in the admin panel.
Code:
list_display = (‘name’, ‘description’)
The list view will now display both name & description fields.
The list_display variable takes a list or tuple as input. You can provide the names of fields you want it to display.
-
Adding a filter in admin
How easy it would be to be able to filter objects. When dealing with a large database, it becomes necessary to see selected information. To perform that task easier, we can add a filter in the list view of the admin panel.
Code:
list_filter = (‘mfg_date’, )
Apply now for Advanced Python Training Course