Questions tagged as 'django-queryset'

1
answer

Using search and pagination field with Function Based View in Django

I have the following code: #decorators.py from django.contrib.auth.decorators import user_passes_test def superuser_required(func): return user_passes_test( lambda u: u.is_authenticated() and u.is_superuser)(func) # views.py @su...
asked by 30.06.2016 / 05:36
0
answers

Applying QuerySets to the data and returning the result of this querySet to the table (django.tables2)

Hello! I'm new to Django and am having a big question: I have following an "Event" model, and a view that is composed of a form (which I use to apply a filter to the data) and a table (where data is loaded ). Well my question is: I want to group...
asked by 06.09.2018 / 20:48
1
answer

How to create tuple with key receiving value?

I would like to create a method that returns the Django ORM FILTER parameters. I will have to use these filters at different times, I would like to create this generic method. Here's the example: def home(selected_page=None): _config = Con...
asked by 05.02.2018 / 18:22
1
answer

How to filter an APIView to show user-related messages?

I want to create a view using APIView, which shows all the messages sent by a user specified in the url. models.py: class Message(models.Model): body = models.CharField(max_length=500) normaluser = models.ForeignKey(User, on_delete=models.C...
asked by 29.01.2018 / 20:18
0
answers

MultipleObjectsReturned

When I create two topics with the same name, the error: MultipleObjectsReturned class ForumView(ListView): paginate_by = 5 template_name = 'forum/forum.html' def get_queryset(self): queryset = Thread.objects.filter()...
asked by 27.03.2017 / 22:29