Skip to content

Instantly share code, notes, and snippets.

@arulmr
Last active December 20, 2015 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arulmr/6175786 to your computer and use it in GitHub Desktop.
Save arulmr/6175786 to your computer and use it in GitHub Desktop.
Auto Complete in Django Admin
class BlockAdmin(NoLookupsForeignKeyAutocompleteAdmin, admin.ModelAdmin):
related_search_fields = {
'city' : ('name', 'state__name', ),
}
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)
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