Last active
December 20, 2015 18:28
-
-
Save arulmr/6175786 to your computer and use it in GitHub Desktop.
Auto Complete in Django Admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BlockAdmin(NoLookupsForeignKeyAutocompleteAdmin, admin.ModelAdmin): | |
… | |
related_search_fields = { | |
'city' : ('name', 'state__name', ), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class State(models.Model): | |
name = models.CharField(max_length = 15) | |
class City(models.Model): | |
state = models.ForeignKey(State) | |
name = models.CharField(max_length = 15) | |
class Block(models.Model): | |
city = models.ForeignKey(City) | |
block = models.CharField(max_length = 15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install -e git+https://github.com/jeremyjbowers/django-autocomplete.git#egg=autocomplete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment