[Fixed]-Get specific user information in Django template

1👍

It looks like you are importing the Django provided user model not your custom user model.

Try changing:

from django.contrib.auth.models import User

To

from django.contrib.auth import get_user_model

Then select your users using get_user_model

def index(request):
    utente = get_user_model().objects.filter(username__in=["user"])
    return render(request,"blog/index.html", {'users' : utente})

Also, make sure that AUTH_USER_MODEL is set to your custom user model in your settings.py file.

AUTH_USER_MODEL = 'myapp.MyUser'

Leave a comment