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...
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...
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...
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...
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()...