Render a model in Django Admin Interface

To render a model in Django admin, we need to modify app/admin.py. Go to admin.py in geeks_site_app and enter the following code. Import the corresponding model from models.py and register it to the admin interface.

Python3




from django.contrib import admin
from .models import GeeksModel
  
# Register your models here.
admin.site.register(GeeksModel,)


Now let’s create a superuser for our project that can have access to the admin area of our site. To create a super user type the below command – 

python manage.py createsuperuser

Now go to http://127.0.0.1:8000/admin on the browser to access the admin interface panel. 

Give the username and password created for superuser and then the admin dashboard will open and there we will be able to see our Geeks models that we just created.

Note: For more information refer to Render Model in Django Admin Interface.

Now let’s see how to enter data using the admin dashboard. Now clicking on the Geeks Model we will see something like this – 

We can click on the Add Geeks Model button on the right top corner and then we will be able to see the fields for adding data. See the below image – 

After adding the required data and the image field we will see something like this on our admin dashboard – 

You can also see the media folder in your code editor –

Python Web Development With Django

Python Django is a web framework that allows to quickly create efficient web pages. Django is also called batteries included framework because it provides built-in features such as Django Admin Interface, default database – SQLite3, etc. When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc. Django gives you ready-made components to use.

Similar Reads

Why Django Framework?

Excellent documentation and high scalability. Used by Top MNCs and Companies, such as Instagram, Disqus, Spotify, Youtube, Bitbucket, Dropbox, etc. and the list is never-ending. Easiest Framework to learn, rapid development, and Batteries fully included. Django is a rapid web development framework that can be used to develop fully fleshed web applications in a short period of time. The last but not least reason to learn Django is Python, Python has a huge library and features such as Web Scraping, Machine Learning, Image Processing, Scientific Computing, etc. One can integrate all this with web applications and do lots and lots of advanced stuff....

Django Architecture

Django is based on MVT (Model-View-Template) architecture which has the following three parts –...

Setting up the Virtual Environment

Most of the time when you’ll be working on some Django projects, you’ll find that each project may need a different version of Django. This problem may arise when you install Django in a global or default environment. To overcome this problem we will use virtual environments in Python. This enables us to create multiple different Django environments on a single computer. To create a virtual environment type the below command in the terminal....

Installing Django

We can install Django using the pip command. To install this type the below command in the terminal....

Starting the project

To initiate a project of Django on Your PC, open Terminal and Enter the following command...

Project Structure

A Django Project when initialized contains basic files by default such as manage.py, view.py, etc. A simple project structure is enough to create a single-page application. Here are the major files and their explanations. Inside the geeks_site folder ( project folder ) there will be the following files-...

Creating an app

Django is famous for its unique and fully managed app structure. For every functionality, an app can be created like a completely independent module. For example, if you are creating a Blog, Separate modules should be created for Comments, Posts, Login/Logout, etc. In Django, these modules are known as apps. There is a different app for each task. Benefits of using Django apps –...

Django Views

...

Django URL Patterns

...

Django Models

A view function is a Python function that takes a Web request and returns a Web response. This response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML document, or an image, anything that a web browser can display. Django views are part of the user interface — they usually render the HTML/CSS/Javascript in your Template files into what you see in your browser when you render a web page....

Uploading Images in Django

...

Render a model in Django Admin Interface

In Django, each view needs to be mapped to a corresponding URL pattern. This is done via a Python module called URLConf(URL configuration). Every URLConf module must contain a variable urlpatterns which is a set of URL patterns to be matched against the requested URL. These patterns will be checked in sequence until the first match is found. Then the view corresponding to the first match is invoked. If no URL pattern matches, Django invokes an appropriate error handling view....

Connecting Django to different Database

...

Django Templates

...

Django Forms

To tackle the above-said problem Django provides something called Django Models....

More on Django

...

Django Projects

...