I think I'm not repeating the question as I couldn't find an answer to my question.
My Model class in models.py is as follows:
class UserDetail(models.Model): user = models.OneToOneField(User) users = User.objects.all() Instance_ID = models.CharField(max_length=10, unique=True) Service_ID = models.CharField(max_length=15, unique=True) Reference_ID = models.CharField(max_length=15, unique=True)
and the admin.py is as follows:
class UserDetailAdmin(admin.ModelAdmin): list_display = ('user','Instance_ID','Service_ID','Reference_ID') search_fields = ('users__User','Instance_ID','Service_ID','Reference_ID')
How do I search the user fields? If I try only 'user' or 'user_id' in the search_fields, I'm getting the following error.
TypeError at /admin/app/UserDetail/ -----> "Related Field got invalid lookup: icontains"
and if I try 'User__users' or 'users__User' or 'users' in the search_fields, I'm getting the following Field Error:
FieldError at /admin/app/UserDetail/ ----> "Cannot resolve keyword 'users' into field. Choices are: Reference_ID, Service_ID, Instance_ID, user, user_id"
what am I doing wrong? Can someone point me in the right direction