django.db.models ForeignKey Python Code Examples

ForeignKey is a Django ORM field-to-column mapping for creating and working with relationships between tables in relational databases.

ForeignKey is defined within the django.db.models.related module but is typically referenced from django.db.models rather than using the related module reference.

Example 1 from AuditLog

Auditlog (project documentation) is a Django app that logs changes to Python objects, similar to the Django admin's logs but with more details and output formats. Auditlog's source code is provided as open source under the MIT license.

AuditLog / src / auditlog_tests / models.py

Example 2 from dccnsys

dccnsys is a conference registration system built with Django. The code is open source under the MIT license.

dccnsys / wwwdccn / review / models.py

Example 3 from django-allauth

django-allauth (project website) is a Django library for easily adding local and social authentication flows to Django projects. It is open source under the MIT License.

django-allauth / allauth / socialaccount / models.py

Example 4 from django-cms

django-cms (project website) is a Python-based content management system (CMS) library for use with Django web apps that is open sourced under the BSD 3-Clause "New" license.

django-cms / cms / migrations / 0018_create_pagenode.py

Example 5 from django-guardian

django-guardian (project documentation and PyPI page) provides per-object permissions in Django projects by enhancing the existing authentication backend. The project's code is open source under the MIT license.

django-guardian / guardian / migrations / 0001_initial.py

Example 6 from django-jet

django-jet (project documentation, PyPI project page and more information) is a fancy Django Admin panel replacement.

The django-jet project is open source under the GNU Affero General Public License v3.0.

django-jet / jet / tests / models.py

Example 7 from django-smithy

django-smithy is a Django code library that allows users to send HTTP requests from the Django admin user interface. The code for the project is open source under the MIT license.

django-smithy / smithy / migrations / 0002_auto_20190317_1052_squashed_0008_auto_20190317_1213.py

Example 8 from gadget-board

gadget-board is a Django, Django REST Framework (DRF) and Angular web application that is open source under the Apache2 license.

gadget-board / web / gadgets / models.py