So, I have a model DailyTask
that has a OneToOneField to the auth_users
model, this is the DailyTask
model fields :
(所以,我有一个模型DailyTask
具有OneToOneField到auth_users
模型,这是DailyTask
模型字段:)
task_id
(task_id)
task_date
(task_date)
user ( OneToOneField )
(用户(OneToOneField))
Now each user
has to submit a new Task
report daily, already have an AdminModel
that display all the submitted Tasks
respectively to the logged in non superuser
, here is the AdminModel
:
(现在,每个user
必须提交新的Task
每日报告,已经有一个AdminModel
是显示所有提交的Tasks
分别向非登录superuser
,这里是AdminModel
:)
class DailyTaskAdmin(admin.ModelAdmin):
def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
return qs.filter(user=request.user)
and I have created a proxy Model
so I can create and register another AdminModel
using the same Model :
(并且我已经创建了一个proxy Model
因此我可以使用相同的模型创建并注册另一个AdminModel
:)
class MyDailyTask(DailyTask):
class Meta:
proxy = True
then the second AdminModel :
(然后是第二个AdminModel:)
class DailyPresenceAdmin(DailyTaskAdmin):
def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
return qs
return qs.filter()
admin.site.register(MyDailyTask, DailyPresenceAdmin)
My only problem is, that in the DailyPresenceAdmin
AdminModel, want to list all the users
from auth_users
that has not uploaded their Task of the day
yet.
(我唯一的问题是,在DailyPresenceAdmin
AdminModel中,要列出auth_users
中尚未上传其Task of the day
所有users
。)
so it will be something like,
(所以会是这样,)
if auth_users.user has no TaskID with the date equals to today's date in the DailyTask Model yet, then I want to take the user and list it in the DailyPresenceAdmin AdminModel.
(如果auth_users.user在DateTask模型中还没有日期等于今天的日期的TaskID,那么我想接收该用户并将其列出在DailyPresenceAdmin AdminModel中。)
ask by DaveMann translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…