我正在使用以下代码:
def show_object(request, category, pk):
# swap out `myapp` to your app name
# if you don't care about url being friendly
# you can use content type primary key instead of model name
model = ContentType.objects.get(app_label="myapp", model=category).model_class()
obj = model.objects.get(pk=pk)
# ...
def show_all_objects(request, category):
model = ContentType.objects.get(app_label="myapp", model=category).model_class()
all_objects = model.objects.all()
# ...
得到这个:
@ibot.event
async def on_member_join(member):
role = discord.utils.get(member.server.roles, name="Test role")
await ibot.add_roles(member, role)