Django Admin CRUD (Create Read Update Delete)
#models.py from django.db import models # Create your models here. class StudentForm(models.Model): firstname = models.CharField("Enter first name", max_length=50) lastname = models.CharField("Enter last name", max_length = 50) email = models.EmailField("Enter Email") file = models.FileField() # for creating file input class Meta: db_table = "student" class Employee(models.Model): name = models.CharField(max_length=100) contact = models.CharField(max_length=100) class Meta: db_table = "employee"
#admin.py from django.contrib import admin # Register your models here. from myapp.models import StudentForm, Employee admin.site.register(StudentForm) # StudentForm is registered admin.site.register(Employee) # Employee is registered
urlpatterns = [
path('admin/', admin.site.urls),
]
http://127.0.0.1:8000/admin/