class QuestionAdmin(admin.ModelAdmin):
ordering = ['date_created']
search_fields = ['question_text']
class ChoiceAdmin(admin.ModelAdmin):
autocomplete_fields = ['question']
а для .pop() нужна итерация
new_dict = {
"a": 1,
"b": 2,
}
a = new_dict.pop("a")
c = new_dict.pop("c", "'c' not exists")
print(new_dict) # {"b": 2}
print(a) # 1
print(c) # 'c' not exists
new_dict.pop("d") # KeyError: 'd'
creator = serializers.SerializerMethodField()
def get_creator(self, obj):
return {"creator": "отредактированная информация в переменной 'creator'"}