您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

获取Django中空查询集的类名

获取Django中空查询集的类名

>>> students = Students.objects.all()

# The queryset's model class:
>>> students.model
project.app.models.Student

# Name of the model class:
>>> students.model.__name__
'Student'

# Import path of the models module:
>>> students.model.__module__
'project.app.models'

# Django app name:
>>> students.model._Meta.app_label
'app'
@H_404_3@
 

          

解决方法

我有 学生 模型的空查询集 __

students = Students.objects.all()

如果以上查询集为空,那么我如何获取模型(类名)?

如何获取空查询集的型号名称?

编辑:

如何从查询集中获取应用名称?

喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!
students = Students.objects.all()

我有 学生 模型的空查询集 __

如果以上查询集为空,那么我如何获取模型(类名)?

如何获取空查询集的型号名称?

编辑:

如何从查询集中获取应用名称?

Go 2022/1/1 18:44:20 有349人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶