Python 为什么 Django 不让我加载新产品?



我在这页:填写详细信息

铃是https://upload.wikimedia.org/wikipedia/commons/c/cb/Oranges_white_background.jpg

当我按下'save'时,它给我这个:错误信息

无法理解的问题,我尝试了各种方法来解决它,如拍另一张照片,重新运行服务器。来自Mosh Hamedi教程:https://www.youtube.com/watch?v=_uQrJ0TkZlc&t=20225s at 05:42:20

编辑:添加代码

models.py

from django.db import models 

class Product(models.Model):
name = models.CharField(max_length=255)
price = models.FloatField()
stock = models.IntegerField()
image_url = models.CharField(max_length=2083)

class Offer(models.Model):
code = models.CharField(max_length=10)
description = models.CharField(max_length=255)
discount = models.FloatField()

views.py

from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello World')

def new(request):
return HttpResponse('New Products')

admin.py

from django.contrib import admin
from .models import Product
admin.site.register(Product)

pyshop - url .py

from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path("products/", include('products.urls'))
]

products - urls.py

from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
path('new', views.new)
]

Django找不到表

main.auth_user__old

注意user和old之间的双下划线。你确定它是正确的吗?

同时,请上传您的代码。

最新更新