에서 사용자 정의 파이썬 스크립트를 실행하고 나는 다음과 같은 오류가 나타납니다장고 모델에서 파이썬 스크립트를 실행하려고 장고 모델
"파일"D를 : \ FL \ 장고 \ 내 사이트 \ uploadfileapp \ models.py " 줄 23, in get_absolute_url Best_model_forecast_v11.main (user_avatar) NameError : 이름 'Best_model_forecast_v11'이 정의되지 않았습니다. ". 위의 스크립트가 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')
'Best_model_forecast_v11'부터 현재 네임 스페이스로 모든 것을 가져옵니다. 그래서 대신'main (user_avatar)'를 호출하고 싶을 것이다. 그 모듈의 발췌 부분을 보지 않고 말하기는 어렵다. 어떤 경우 이건 - 이것은 효과가 있습니다. 그냥 제대로 가져 오지 못했습니다. – Shadow
확인. 어떻게 올바르게 가져올 수 있습니까? 고맙습니다. –
나는 모듈을 보지 않고 블라인드 비행을하고있다. 그러나 나는'from uploadfileapp import Best_model_forecast_v11'와 같이 가정 할 것이다. – Shadow