Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
Django why getting this error No user profile found matching the query

I am trying to implement load more button so I am writing this view for load json data but I am not understanding why I am getting this error. No user profile found matching the query Raised by: members.views.UserProfileUpdate

here is my view:

class PostJsonListView(View):
    def get(self, *args, **kwargs):
        print(kwargs)
        upper = kwargs.get('num_posts')
        lower = upper - 3 
        posts = list(Blog.objects.values()[lower:upper])
        posts_size = len(Blog.objects.all())
        max_size = True if upper >= posts_size else False
        return JsonResponse({'data': posts, 'max': max_size}, safe=False)

this is my blog app urls.py

path('posts-json/<int:num_posts>',PostJsonListView.as_view(),name='json-view')

this is my members app urls.py

path('<slug:slug>/', UserProfileUpdate.as_view(), name='update-profile'),

if I put any wrong url like this http://127.0.0.1:8000/sassassdsadasdd/ giving me the same error No user profile found matching the query Raised by: members.views.UserProfileUpdate

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you are in the UserProfileUpdate view, using the slug for getting the profile object like this:

Profile.objects.get(username=slug)

but! you should use the get_object_or_404 shortcut functions.

from django.shortcuts import get_object_or_404
get_object_or_404(Profile, username=slug)

refrence

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda