Файл models.py
from django.db import models
class customer(models.Model):
name=models.CharField(max_length=200 )
phone=models.CharField(max_length=200 )
email= models.CharField(max_length=200 )
data_created = models.DateTimeField(auto_now_add=True)
def _self_(self):
return self.name
class Tag(models.Model):
name=models.CharField(max_length=200 )
def _self_(self):
return self.name
class product(models.Model):
CATEGORY= (
('Indoor','Indoor'),
('Out Door', 'Out Door'),
)
name=models.CharField(max_length=200 , null=True)
price = models.FloatField(null=True)
category =models.CharField(max_length=200 , null=True, choices=CATEGORY)
description =models.CharField(max_length=200 , null=True)
date_created = models.DateTimeField(auto_now_add=True)
tags= models.ManyToManyField(Tag)
class order(models.Model):
STATUS= (
('Pending','Pending'),
('Out for delivery', 'Out for delivery'),
('Delivery','Delivery'),
)
customer = models.ForeignKey(customer,null=True , on_delete= models.SET_NULL)
product = models.ForeignKey(product, null=True , on_delete= models.SET_NULL)
date_created = models.DateTimeField(auto_now_add=True)
status =models.CharField(max_length=200 , null=True, choices=STATUS)
Файл views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import *
def home(request):
return render(request, 'dashboard.html')
def products(request):
products= product.objects.all()
return render(request,'products.html',{'products':products})
def customer(request):
return render(request, 'customer.html')
Ошибки:
- Класс «продукт» не имеет «объектов» элемент pylint (без элемента) [9,15].
- функция уже определена, строка 3 pylint (функция-переопределена) [12,3].