Based on first idea and implementation from Marco Beri and Stefano Brentegani here packaged as a django app with some test cases added
Download the repo:
git clone https://github.com/depaolim/django_smart_raw_id.git
Add this folder to your pythonpath
The app is tested on Django 1.6 and has no dependency from other packages (apart from django itsef)
In your project do the following steps:
-
Add the app smart_raw_id to INSTALLED_APPS in your settings.py
-
Use SmartRawIdMixin as a mixin class for your model admin classes
The following is an an example of usage in your admin.py
from smart_raw_id import SmartRawIdMixin
class SingleSaleAdmin(SmartRawIdMixin, ModelAdmin):
list_display = ('id', 'product', 'price')
raw_id_fields = ('product', )
To deploy remember to do:
python manage.py collectstatic
To run tests you need selenium as stated by requirements_dev.txt
pip install -r requirements_dev.txt
cd django_smart_raw_id
python manage.py test
LiveServerTestCase and selenium could have timeout problems. In such case you must restart the test