Reputation: 922
I am new with python and django, i want to know how can i implement the admin search bar on my project model? i notice that the user model has it by default.
My code is below, after the makemigration command still no search bar i think i am missing something. sorry for the noob question.
class Todo(models.Model):
search_fields = ('title', 'text', 'created_at',)
title = models.CharField(max_length=200)
text = models.TextField()
created_at = models.DateTimeField(default=datetime.now)
def __str__(self):
return self.title
Upvotes: 0
Views: 378
Reputation: 27513
in the apps
admin.py
inside the class for which you are registering the model
add
search_fields = ['column_name']
Upvotes: 2