Commits

Mark Lavin committed ed83a83

Add lookup hooks for adding new items.

Comments (0)

Files changed (1)

selectable/base.py

+import re
 from django.core.urlresolvers import reverse
 from django.core.serializers import json
 from django.http import HttpResponse
     def get_item(self, value):
         return None
 
+    def create_item(self, value):
+        raise NotImplemented()
+
     def format_item(self, item):
          return {
             'id': self.get_item_id(item),
                 pass
         return item
 
+    def create_item(self, value):
+        data = {}
+        if self.search_field:
+            field_name = re.sub(r'__\w+$', '',  self.search_field)
+            if field_name:
+                data = {field_name: value}
+        return self.model(**data)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.