Django get_object Not found

Viewed 111

On two different PCs I run same code, which contains 'get_object_or_404'

user = get_object_or_404(User, username = self.kwargs.get('username'))

On my PC it runs ok, I get 'MVidić' as value.

On other PC I get:

MVidi%C4%87:1 GET http://app.local/user/MVidi%C4%87 404 (Not Found)

Why is that? Is it some localization setting? All Django/Python files are the same on both PCs. When user is a person without diacritic simbols it works ok.

views.py

class UserPostListView(ListView):
    model = Post
    template_name = 'blog/user_posts.html'
    context_object_name = 'posts'
    paginate_by = 5

    def get_queryset(self):
        user = get_object_or_404(User, username = self.kwargs.get('username'))
        user_id=user.id
        return Post.objects.filter(author=user_id).order_by('-date_posted')

models.py

from django.db import models
from django.contrib.auth.models import User

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)

settings.py

LANGUAGE_CODE = 'hr-BA'
TIME_ZONE = 'Europe/Zagreb'
USE_I18N = True
USE_L10N = True
USE_TZ = True
0 Answers
Related