[Answer]-Python django – user object not found

1👍

The whole piece of code is unnecessary. self.user is already an instance of User. There’s absolutely no point getting that user’s username and using that to query the User model again: you’d just get back the exact same data you started with.

Just use self.user directly.

0👍

do this

from django.views import generic
class GetUserData(generic.View):
    def get(self, *args, **kwargs):
        user = self.request.user
        if user.username:
            myuser = UserData.objects.filter(username=user.username)
            if myuser:
                print 'coo'
            else:
                print 'nope'

If the data is coming from Get request then do this:

get_data = self.request.GET  # Parse get set after then blammo

Leave a comment