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
b55624a0
Kaydet (Commit)
b55624a0
authored
Haz 02, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added get_app_paths() to the AppCache.
This method is useful to discover files inside apps.
üst
09d05686
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
__init__.py
django/db/models/__init__.py
+1
-1
loading.py
django/db/models/loading.py
+21
-1
No files found.
django/db/models/__init__.py
Dosyayı görüntüle @
b55624a0
from
functools
import
wraps
from
django.core.exceptions
import
ObjectDoesNotExist
,
ImproperlyConfigured
from
django.db.models.loading
import
get_apps
,
get_app
,
get_models
,
get_model
,
register_models
from
django.db.models.loading
import
get_apps
,
get_app
_paths
,
get_app
,
get_models
,
get_model
,
register_models
from
django.db.models.query
import
Q
from
django.db.models.expressions
import
F
from
django.db.models.manager
import
Manager
...
...
django/db/models/loading.py
Dosyayı görüntüle @
b55624a0
...
...
@@ -130,7 +130,9 @@ class AppCache(object):
return
self
.
loaded
def
get_apps
(
self
):
"Returns a list of all installed modules that contain models."
"""
Returns a list of all installed modules that contain models.
"""
self
.
_populate
()
# Ensure the returned list is always in the same order (with new apps
...
...
@@ -140,6 +142,23 @@ class AppCache(object):
apps
.
sort
()
return
[
elt
[
1
]
for
elt
in
apps
]
def
get_app_paths
(
self
):
"""
Returns a list of paths to all installed apps.
Useful for discovering files at conventional locations inside apps
(static files, templates, etc.)
"""
self
.
_populate
()
app_paths
=
[]
for
app
in
self
.
get_apps
():
if
hasattr
(
app
,
'__path__'
):
# models/__init__.py package
app_paths
.
extend
([
upath
(
path
)
for
path
in
app
.
__path__
])
else
:
# models.py module
app_paths
.
append
(
upath
(
app
.
__file__
))
return
app_paths
def
get_app
(
self
,
app_label
,
emptyOK
=
False
):
"""
Returns the module containing the models for the given app_label. If
...
...
@@ -260,6 +279,7 @@ cache = AppCache()
# These methods were always module level, so are kept that way for backwards
# compatibility.
get_apps
=
cache
.
get_apps
get_app_paths
=
cache
.
get_app_paths
get_app
=
cache
.
get_app
get_app_errors
=
cache
.
get_app_errors
get_models
=
cache
.
get_models
...
...
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