Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
84d8d1d7
Kaydet (Commit)
84d8d1d7
authored
Haz 03, 2016
tarafından
Evan Palmer
Kaydeden (comit)
Tim Graham
Haz 04, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25127 -- Documented how to organize models in a package.
üst
dc88516e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
models.txt
docs/topics/db/models.txt
+24
-0
No files found.
docs/topics/db/models.txt
Dosyayı görüntüle @
84d8d1d7
...
...
@@ -1410,6 +1410,30 @@ different database tables).
Django will raise a :exc:`~django.core.exceptions.FieldError` if you override
any model field in any ancestor model.
Organizing models in a package
==============================
The :djadmin:`manage.py startapp <startapp>` command creates an application
structure that includes a ``models.py`` file. If you have many models,
organizing them in separate files may be useful.
To do so, create a ``models`` package. Remove ``models.py`` and create a
``myapp/models/`` directory with an ``__init__.py`` file and the files to
store your models. You must import the models in the ``__init__.py`` file.
For example, if you had ``organic.py`` and ``synthetic.py`` in the ``models``
directory:
.. snippet::
:filename: myapp/models/__init__.py
from .organic import Person
from .synthetic import Robot
Explicitly importing each model rather than using ``from .models import *``
has the advantages of not cluttering the namespace, making code more readable,
and keeping code analysis tools useful.
.. seealso::
:doc:`The Models Reference </ref/models/index>`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment