django-admin-sortable/sample_project/appmedia/api.py
Brandon Taylor 37f91cce97 Added SortableForeignKey field to replace sortable_by model property.
Refactored how the sortable_by properties get populated by looping over the model fields until we get to the SortableForeignKey, then grabbing properties from the field and its related data.
2012-02-24 22:35:30 -06:00

15 lines
No EOL
464 B
Python

import os, os.path as osp
from django.conf import settings
from django.db.models import get_apps
def get_app_resource(app, path):
apps = get_apps()
for x in apps:
app_dir = osp.dirname(x.__file__)
if app == x.__name__.split('.')[-2]:
resource_dir = osp.join(app_dir, "resources")
asset = osp.join(resource_dir, path)
if osp.exists(asset):
return asset
continue