从django admin隐藏网站标签

时间:2022-11-11 22:25:33

I am a beginner in django and i used sites framework to make multiple instances of a website use the same code and database but in my django admin page i noticed that it display a label site in each model to make the get or create queries based on the selected site but i want to make it use the current site to get or create objects and remove this selection from all models.

我是django的初学者,我使用网站框架来使网站的多个实例使用相同的代码和数据库,但在我的django管理页面中,我注意到它在每个模型中显示一个标签网站,以便根据获取或创建查询选定的网站,但我想让它使用当前网站来获取或创建对象,并从所有模型中删除此选择。

how can i do this ? thanks.

我怎样才能做到这一点 ?谢谢。

This is the admin.py code in my models:

这是我模型中的admin.py代码:

from survey.models import *    
from django.forms.models import ModelForm
from django.forms.widgets import RadioSelect
from django import forms
from django.utils.safestring import mark_safe
from django.contrib import admin

admin.site.register(AnswerRange, AnswerRangeAdmin)
admin.site.register(Role,RolAdmin)
admin.site.register(Indicator, IndicatorAdmin)
admin.site.register(CharacteristicCategory)
admin.site.register(Characteristic, CharacteristicAdmin)
admin.site.register(Practice, PracticeAdmin)
admin.site.register(UserProfile, UserProfileAdmin)
admin.site.register(Macro)
admin.site.register(ReportPassword)
admin.site.register(Demographic, DemographicAdmin)
admin.site.register(Message)
admin.site.register(Comment)
admin.site.register(InstanceSetting)
admin.site.register(UsersWaitingList)
admin.site.register(ticket)
admin.site.register(Answer)
admin.site.register(Option)

1 个解决方案

#1


0  

I have solved it by adding exclude = ('Site',) in a custom Admin class for each model and add it in the admin registration like this:

我通过在每个模型的自定义Admin类中添加exclude =('Site')来解决它,并将其添加到admin注册中,如下所示:

admin.site.register(Model, CustomModelAdmin)

#1


0  

I have solved it by adding exclude = ('Site',) in a custom Admin class for each model and add it in the admin registration like this:

我通过在每个模型的自定义Admin类中添加exclude =('Site')来解决它,并将其添加到admin注册中,如下所示:

admin.site.register(Model, CustomModelAdmin)