Category : django-views

I am building chat app and I am using Django Version 3.8.1. I am stuck on Error. This view is for Chat with friend private. views. def chat_friend(request, pk): # Chat info friend = get_object_or_404(User, pk=pk) chat_box = ChatBox.objects.filter( user_1=request.user, user_2=friend).first() if not chat_box: chat_box = ChatBox.objects.filter( user_1=friend, user_2=request.user).first() for message in Message.objects.filter(Q(is_read=False), ~Q(message_sender=request.user)): message.is_read ..

Read more

I have a view that is used to update a field in my model. It’s represented as follows: stock_list = ArrayField(models.CharField()) Each value in the ArrayField is separated by commas. I used a custom serializer method to allow for my backend to separate the elements in my PATCH obj by commas. serializers.py: class StringArrayField(ListField): """ ..

Read more

can i please get an help in what i’m doing wrong? i have a boolean field in which i want when a user clicks on it, it updates in the database, but i can’t achieve my aim. my code is below for better understanding models.py class OrderItem(models.Model): designer_size = models.ForeignKey("Frame_Sizes_Designer", on_delete=models.CASCADE, blank=True) ***** class Frame_Sizes_Designer(models.Model): ..

Read more