这就是全部,我想知道怎么做我可以编辑我的数据库上的主键,我已经尝试创建一个model.Admin with list_editable并设置'id'但它没有工作
class ArticleAdmin(admin.ModelAdmin):
list_display = ('article_title','article_body','article_state','id')
list_editable = ('id','article_state',)
想法?
答案 0 :(得分:0)
要更改订单,您可以添加订单字段:
class Article(models.Model):
order = models.IntegerField(default=0)
class Meta:
ordering = ['order']
def save(self, *args, **kwargs):
# Not quite sure you would want to do this but it's at least an option.
if self.order == 0 and self.pk:
self.order = self.pk