Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Django Tutorial: Adding Our Model To The Django Admin Site

  • Code master
  • 2016-07-23
  • 5757
Django Tutorial: Adding Our Model To The Django Admin Site
add model in django administrationregister model to django admindjango admin tutorialadding a table to admin page djangohow to add model to django adminhow to add register to django admindjango admin site registeradmin.pyadd data in tables in django admin pagedjango admin one to manydjango tutorialdjango class metadjango admin sitedjango admin modeladmin django create commentsclass meta djangodjango admin for finished sitedjango admin
  • ok logo

Скачать Django Tutorial: Adding Our Model To The Django Admin Site бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Django Tutorial: Adding Our Model To The Django Admin Site или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Django Tutorial: Adding Our Model To The Django Admin Site бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Django Tutorial: Adding Our Model To The Django Admin Site

Check out our Django 2.0 tutorials at https://www.mastercode.online/courses...

In this Django tutorial, we are going to learn how to add a model to the Django administration site. This process is pretty simple. The way the Django framework is designed allows for us to add our models to the Django administration site in just a few lines of code.

Add A Model To The Django Administration Site
Now that we have created our model and migrated the model to the database we are able to use admin site. First open your admin.py file in your text editor. The admin.py file lookes like.

from django.contrib import admin

Register your models here.
Right now all this file does is import admin from django.contrib. The admin is a package that is included in contrib and this package requires two other packages auth and contenttypes. These two packages should be already be in the installed apps unless you removed them. The contrib is a directory which is included in the Django framework that contains many packages we can use in our Django project. Django likes to include many useful packages with their framework if you would like to see more visit https://docs.djangoproject.com/en/1.9...

The admin package has a ton of features which we can not cover in one tutorial so we will cover a few here and follow up later to cover more admin features.

Import Our Model
For us to be able to access the model in our app we need to import the model into admin.py. This is pretty simple task. Take a look at the code below.

from django.contrib import admin

Register your models here.
from .models import Lesson
In the above code we are saying from .models which is the model contained in the same app import our class Lesson(which is a table). Now that we have added this line we are able to access the meta data in our models.py file.

If we ran the server now and looked at our admin site we would not see anything change. We need to still register the class(database table) for the admin interface to interact with the database.

Register Class
To register the class we need to use the following code admin.site.register(class name) so in this case we would use the following code.

from django.contrib import admin

Register your models here.
from .models import Lesson

admin.site.register(Lesson)
Now open up your site and go to the admin section. You will see a new section called Lessons.

add model to admin site django
Now if you click on add you can add a lesson. If you click on change you can change a lesson and if you click on lessons you can see all the lessons. Pretty cool.

Conclusion
In this Django tutorial, we took a look at how to to add a model to the Django administration site. If you have any questions leave a comment below. In the next tutorial we will look at different ways to improve the admin interface for this app.

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]