我在python中编码,我有以下问题:
我有模特:
class Employee(models.Model):
BadgeBarcode = models.CharField(max_length=40)
ManagerName = models.CharField(max_length=40)
EmployeeName = models.CharField(max_length=40)
UserLogin = models.CharField(max_length=40)
ShiftPattern = models.CharField(max_length=40)
def Add(self):
self.save()
def __str__(self):
return self.EmployeeName
class Permission(models.Model):
Permission_Name = models.CharField(max_length=40)
Priority = models.IntegerField(unique=True)
def Add(self):
self.save()
def __str__(self):
return self.Permission_Name
class EmployeePermission(models.Model):
Employee = models.ForeignKey(Employee)
Permission = models.ForeignKey(Permission)
Have = models.BooleanField()
def Add(self):
self.save()
def __str__(self):
return self.Employee
我想连接Model Employee和Permission以及它的所有工作正常。但是我喜欢7k的员工记录,当我想为员工添加新的权限时,员工列表太大而页面工作就像...它有什么方法可以解决这个问题或更改搜索按钮或其他内容的列表?
class EmployeeAdmin(admin.ModelAdmin):
list_display = ( 'id','EmployeeName','UserLogin',
'ManagerName','ShiftPattern','BadgeBarcode')
list_filter = ( 'ManagerName','ShiftPattern')
class EmployeeResources(resources.ModelResource):
class Meta:
model = Employee
class ExportEmployeeAdmin(ImportExportModelAdmin):
resource_class = EmployeeResources
list_filter = ( 'ManagerName','ShiftPattern')
list_display = ('id','EmployeeName','UserLogin','here many field...' )
admin.site.register(Employee,ExportEmployeeAdmin)
class PermissionResources(resources.ModelResource):
class Meta:
model = Permission
class ExportPermissionAdmin(ImportExportModelAdmin):
resource_class = PermissionResources
list_display = ('Permission_Name', 'Priority')
list_filter = ('Permission_Name', 'Priority')
admin.site.register(Permission,ExportPermissionAdmin)
class EmployeePermissionResources(resources.ModelResource):
class Meta:
model = EmployeePermission
class ExportEmployeePermissionAdmin(ImportExportModelAdmin):
resource_class = EmployeePermissionResources
list_display = ('Employee','Permission', 'Have')
list_filter = ('Employee','Permission', 'Have')
admin.site.register(EmployeePermission,ExportEmployeePermissionAdmin)