Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django add model

### 1- in models.py file add your model class ###
from django.db import models

class Product(models.Model):
       name = models.CharField(max_length=20, help_text='product name')
       price = models.FloatField(help_text='product price')
       date = models.DateField(help_text='product date')
       image = models.ImageField(upload_to='images/%y/%m/%d', help_text='product image')

### 2- in admin.py file register the model ###
from django.contrib import admin

admin.site.register(Product)
 
PREVIOUS NEXT
Tagged: #django #add #model
ADD COMMENT
Topic
Name
2+9 =