Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python bash command 
Python :: python rsa 
Python :: how to take unknown number of inputs in python 
Python :: plot histogram python 
Python :: simple time in python 
Python :: numpy generate random 2d array 
Python :: how to run django tests 
Python :: python list of integers 
Python :: python turn true or false into 0 or 1 
Python :: python os remove extension 
Python :: how to get something from a certian possition in a list python 
Python :: tkinter keep window in front 
Python :: how to run python file from cmd in dockerfile 
Python :: numpy remove element 
Python :: convex hull algorithm python 
Python :: how to convert string date to timestamp in python 
Python :: IntegrityError import in django 
Python :: how to replace first line of a textfile python 
Python :: python import worldcloud 
Python :: python numba 
Python :: difference between compiler and interpreter 
Python :: python save output to file 
Python :: python list all files of directory in given pattern 
Python :: python delete white spaces 
Python :: set cookie in chrome 
Python :: UTC to ISO 8601: 
Python :: spacy nlp load 
Python :: tkinter frame example 
Python :: for loop in django 
Python :: count values in numpy list python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =