from django.contrib import admin
-import models
+from karmaworld.apps.courses.models import School
+from karmaworld.apps.courses.models import Course
-admin.site.register(models.School)
-admin.site.register(models.Course)
+class CourseAdmin(admin.ModelAdmin):
+ """ an Admin handler for the Course model that handles fk search """
+ raw_id_fields = ('school',)
+ autocomplete_lookup_fields = {
+ 'fk': ['school']
+ }
+
+admin.site.register(School)
+admin.site.register(Course, CourseAdmin)
self.slug = defaultfilters.slugify(self.name)
super(School, self).save(*args, **kwargs)
+ @staticmethod
+ def autocomplete_search_fields():
+ return ("name__icontains",)
+
def update_note_count(self):
""" Update the School.file_count by summing the
contained course.file_count
# Useful template tags:
'django.contrib.humanize',
+ # grappelli django-admin improvment, must be added before admin
+ 'grappelli',
+
# Admin panel and documentation:
'django.contrib.admin',
'django.contrib.admindocs',
# Admin panel and documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
+ # Grappelli django-admin improvment suite
+ url(r'^grappelli/', include('grappelli.urls')),
url(r'^terms/$', direct_to_template, { 'template': 'terms.html' }, name='terms'),
oauth2client==1.0
urllib3==1.5
google-api-python-client==1.0
+django-grappelli==2.4.3