您好,我需要在django管理员中导入excel文件,我找到了此视频,并应用了步骤,但是我有行号:1 - name 'name' is not defined error
该如何解决?
models.py
from django.db import models
class Ekle(models.Model):
name = models.CharField(max_length = 50, blank = False)
lastname = models.CharField(max_length = 50)
price = models.CharField(max_length = 50)
def __str__(self):
return name
admin.py
from django.contrib import admin
from .models import *
from import_export.admin import ImportExportModelAdmin
@admin.register(Ekle)
class ViewAdmin(ImportExportModelAdmin):
pass
答案 0 :(得分:0)
您需要同时使用self:
def __str__(self):
return "%s" % self.name