... name> # A field from another model that has a relation with the current model >>> User . _meta . get_field ( "logentry" ) <ManyToOneRel: admin.logentry> # A non existent field >>> User . _meta . get_field ( "does_not_exist" ) Traceback (most recent call last ... will include fields with hidden=True . >>> from django.contrib.auth.models import User >>> User . _meta . get_fields () (<ManyToOneRel: admin.logentry>, <django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: password>, <django.db.model ... anyToManyField: user_permissions>) # Also include hidden fields. >>> User . _meta . get_fields ( include_hidden = True ) (<ManyToOneRel: auth.user_groups>, <ManyToOneRel: auth.user_user_permissions>, <ManyToOneRel: admin.logentry>, <django.db.models.fields.A ... ... name> # A field from another model that has a relation with the current model >>> User . _meta . get_field ( "logentry" ) <ManyToOneRel: admin.logentry> # A non existent field >>> User . _meta . get_field ( "does_not_exist" ) Traceback (most recent call last ... will include fields with hidden=True . >>> from django.contrib.auth.models import User >>> User . _meta . get_fields () (<ManyToOneRel: admin.logentry>, <django.db.models.fields.AutoField: id>, <django.db.models.fields.CharField: password>, <django.db.model ... anyToManyField: user_permissions>) # Also include hidden fields. >>> User . _meta . get_fields ( include_hidden = True ) (<ManyToOneRel: auth.user_groups>, <ManyToOneRel: auth.user_user_permissions>, <ManyToOneRel: admin.logentry>, <django.db.models.fields.A ... ... ribute set to the source of the relationship. Now, this method returns the relationship as django.db.models.fields.related.ManyToOneRel (private API RelatedObject has been removed), and the model attribute is set to the target of the relationship instead of ... mple from the tutorial in Django 1.8: >>> p = Poll . objects . get ( pk = 1 ) >>> p . _meta . get_all_related_objects () [<ManyToOneRel: polls.choice>] >>> p . _meta . get_all_related_objects ()[ 0 ] . model <class 'polls.models.Poll'> >>> p . _meta . get_al ... ... ribute set to the source of the relationship. Now, this method returns the relationship as django.db.models.fields.related.ManyToOneRel (private API RelatedObject has been removed), and the model attribute is set to the target of the relationship instead of ... mple from the tutorial in Django 1.8: >>> p = Poll . objects . get ( pk = 1 ) >>> p . _meta . get_all_related_objects () [<ManyToOneRel: polls.choice>] >>> p . _meta . get_all_related_objects ()[ 0 ] . model <class 'polls.models.Poll'> >>> p . _meta . get_al ... ... <object pk= "27" model= "auth.permission" > <!-- ... --> <field to= "contenttypes.contenttype" name= "content_type" rel= "ManyToOneRel" > 9 </field> <!-- ... --> </object> この例では、PK 27の auth.Permission オブジェクトが、PK 9の contenttypes.ContentType イ ... ... <object pk= "27" model= "auth.permission" > <!-- ... --> <field to= "contenttypes.contenttype" name= "content_type" rel= "ManyToOneRel" > 9 </field> <!-- ... --> </object> この例では、PK 27の auth.Permission オブジェクトが、PK 9の contenttypes.ContentType イ ... 2026年10月08日