Permalink
Browse files

Fixed #51 - updated grappelli related codes so we support their v2.3.…

…3 + updated example to use staticfiles from Django 1.3
  • Loading branch information...
1 parent 82fa3f0 commit a21b044711266534eaef5e58397d0701ec101058 @lukaszb lukaszb committed Sep 5, 2011
Showing with 9 additions and 5 deletions.
  1. +6 −3 example_project/settings.py
  2. +2 −2 example_project/urls.py
  3. +1 −0 guardian/admin.py
View
9 example_project/settings.py
@@ -30,19 +30,20 @@
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.messages',
+ 'django.contrib.staticfiles',
'guardian',
'guardian.tests',
#'south',
#'django_coverage',
'posts',
)
-if django.VERSION < '1.3':
+if 'GRAPPELLI' in os.environ:
try:
__import__('grappelli')
INSTALLED_APPS = ('grappelli',) + INSTALLED_APPS
except ImportError:
- pass
+ print "django-grappelli not installed"
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
@@ -53,9 +54,11 @@
'django.middleware.transaction.TransactionMiddleware',
)
+STATIC_ROOT = abspath(PROJECT_ROOT, '..', 'public', 'static')
+STATIC_URL = '/static/'
MEDIA_ROOT = abspath(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
-ADMIN_MEDIA_PREFIX = '/admin-media/'
+ADMIN_MEDIA_PREFIX = STATIC_URL + 'grappelli/'
ROOT_URLCONF = 'example_project.urls'
View
4 example_project/urls.py
@@ -18,9 +18,9 @@
if settings.DEBUG:
urlpatterns += patterns('',
- (r'^%s/(?P<path>.*)$' % settings.MEDIA_URL.strip('/'),
+ (r'^%s/(?P<path>.*)$' % settings.STATIC_URL.strip('/'),
'django.views.static.serve',
- {'document_root': settings.MEDIA_ROOT}),
+ {'document_root': settings.STATIC_ROOT}),
)
if 'grappelli' in settings.INSTALLED_APPS:
View
1 guardian/admin.py
@@ -151,6 +151,7 @@ def get_obj_perms_base_context(self, request, obj):
related content.
"""
context = {
+ 'adminform': {'model_admin': self},
'object': obj,
'app_label': self.model._meta.app_label,
'opts': self.model._meta,

0 comments on commit a21b044

Please sign in to comment.