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
ff445f4c
Kaydet (Commit)
ff445f4c
authored
Agu 11, 2016
tarafından
Kevin Christopher Henry
Kaydeden (comit)
Tim Graham
Agu 17, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26616 -- Clarified model usage in AppConfig.ready().
üst
4773ed2e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
applications.txt
docs/ref/applications.txt
+17
-3
No files found.
docs/ref/applications.txt
Dosyayı görüntüle @
ff445f4c
...
...
@@ -239,13 +239,27 @@ Methods
as registering signals. It is called as soon as the registry is fully
populated.
You cannot import models in modules that define application configuration
classes, but you can use :meth:`get_model` to access a model class by
name, like this::
Although you can't import models at the module-level where
:class:`~django.apps.AppConfig` classes are defined, you can import them in
``ready()``, using either an ``import`` statement or
:meth:`~AppConfig.get_model`.
If you're registering :mod:`model signals <django.db.models.signals>`, you
can refer to the sender by its string label instead of using the model
class itself.
Example::
from django.db.models.signals import pre_save
def ready(self):
# importing model classes
from .models import MyModel # or...
MyModel = self.get_model('MyModel')
# registering signals with the model's string label
pre_save.connect(receiver, sender='app_label.MyModel')
.. warning::
Although you can access model classes as described above, avoid
...
...
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