尝试从Django模型执行python脚本,我收到以下错误:
File "D:\FL\Django\mysite\uploadfileapp\models.py", line 23, in get_absolute_url Best_model_forecast_v11.main(user_avatar) NameError: name 'Best_model_forecast_v11' is not defined
上述脚本与models.py
from django.db import models
from uploadfileapp.Best_model_forecast_v11 import *
# Create your models here.
from django.urls import reverse
class User(models.Model):
#the variable to take the inputs
user_name = models.CharField(max_length=100)
user_avatar = models.FileField()
# on submit click on the user entry page, it redirects to the url below.
def get_absolute_url(self):
Best_model_forecast_v11.main(user_avatar)
return reverse('uploadfileapp:home')
答案 0 :(得分:1)
您输入的文件不正确,请更改:
from uploadfileapp.Best_model_forecast_v11 import *
到
from uploadfileapp.models.Best_model_forecast_v11 import *