Permalink
Browse files

django 1.4 compatibility: bundle icons removed from 1.4, fix missing …

…ADMIN_MEDIA_PREFIX, support new required widget constructor parameter
  • Loading branch information...
1 parent da0fd1c commit 01c9e2c601526b78961c69263c27f68e7f6aae41 @kmike kmike committed Mar 5, 2012
View
@@ -20,11 +20,19 @@ pip from source
You can also install with pip straight from the `github.com`_ repository::
$ pip install git+http://github.com/lincolnloop/django-salmonella.git#egg=django-salmonella
-
-
+
+
Finally
*******
+Add a record to your project's urls::
+
+ urlpatterns = patterns('',
+ # ...
+ url(r'^admin/salmonella/', include('salmonella.urls')),
+ # ...
+ )
+
Add ``salmonella`` to your project's ``INSTALLED_APPS`` and you should be ready to go::
INSTALLED_APPS = (
View
@@ -6,15 +6,21 @@ class SalmonellaMixin(object):
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
if db_field.name in self.salmonella_fields:
- kwargs['widget'] = SalmonellaIdWidget(db_field.rel)
+ try:
+ kwargs['widget'] = SalmonellaIdWidget(db_field.rel)
+ except TypeError: # django 1.4+
+ kwargs['widget'] = SalmonellaIdWidget(db_field.rel, self.admin_site)
return db_field.formfield(**kwargs)
return super(SalmonellaMixin, self).formfield_for_foreignkey(db_field,
request,
**kwargs)
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
if db_field.name in self.salmonella_fields:
- kwargs['widget'] = SalmonellaMultiIdWidget(db_field.rel)
+ try:
+ kwargs['widget'] = SalmonellaMultiIdWidget(db_field.rel)
+ except TypeError: # django 1.4+
+ kwargs['widget'] = SalmonellaIdWidget(db_field.rel, self.admin_site)
kwargs['help_text'] = ''
return db_field.formfield(**kwargs)
return super(SalmonellaMixin, self).formfield_for_manytomany(db_field,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,8 +1,8 @@
{{ hidden_input }}
<a href="{{related_url }}{{ url }}" data-name="{{ name }}" data-app="{{ app_name }}" data-model="{{ model_name }}" class="salmonella-related-lookup" id="lookup_id_{{ name }}" >
- <img src="{{ admin_media_prefix }}img/admin/selector-search.gif" alt="Lookup" height="16" width="16">
+ <img src="{{ SALMONELLA_STATIC }}img/selector-search.gif" alt="Lookup" height="16" width="16">
</a>
<a data-name="developers" data-app="{{ app_name }}" data-model="{{ model_name }}" class="salmonella-clear-field">
- <img src="{{ admin_media_prefix }}img/admin/icon_deletelink.gif" alt="Lookup" height="10" width="10">
+ <img src="{{ SALMONELLA_STATIC }}img/icon_deletelink.gif" alt="Lookup" height="10" width="10">
</a>
<span class="salmonella_label" id="{{ name }}_salmonella_label"></span>
View
@@ -30,7 +30,7 @@ def render(self, name, value, attrs=None, multi=False):
'model_name': model_name,
'related_url': related_url,
'url': url,
- 'admin_media_prefix': settings.ADMIN_MEDIA_PREFIX,
+ 'SALMONELLA_STATIC': settings.STATIC_URL + 'salmonella/'
}
return render_to_string('salmonella/admin/widgets/salmonella_field.html',
extra_context)
View
@@ -11,7 +11,13 @@
description=("raw_id_fields widget replacement that handles display of an object's "
"string value on change and can be overridden via a template."),
packages=find_packages(),
- package_data={'salmonella': ['static/salmonella/js/*.js', 'templates/salmonella/*.html', 'templates/salmonella/admin/widgets/*.html']},
+ package_data={'salmonella': [
+ 'static/salmonella/js/*.js',
+ 'static/salmonella/img/*.gif',
+ 'templates/salmonella/*.html',
+ 'templates/salmonella/admin/*.html',
+ 'templates/salmonella/admin/widgets/*.html'
+ ]},
url="http://github.com/lincolnloop/django-salmonella/",
install_requires=['setuptools'],
classifiers=[

0 comments on commit 01c9e2c

Please sign in to comment.