django

Cause of this error: No List matches the given query

Cause of this error: No List matches the given query Question: The user can add that product to the watch list by clicking on the add button, and then the add button will change to Rimo. And this time by clicking this button, the product will be removed from the list. There should be a …

Total answers: 2

Offcanvas dismiss button does not work when instance initialised via Javascript

Offcanvas dismiss button does not work when instance initialised via Javascript Question: I have offcanvas as part of the page layout. It does not show by default, but I want it to always show on large screens. On small screens it should have a button to dismiss it. Another button to show the offcanvas is …

Total answers: 1

Is it possible to make Django urlpatterns from a string?

Is it possible to make Django urlpatterns from a string? Question: I have a list of strings that is used to define navigation pane in a Django layout template. I want to use the same list for view function names and use a loop to define urlpatterns in urls.py accordingly. Example: menu = ["register", "login", …

Total answers: 1

Form with hidden field not submitting

Form with hidden field not submitting Question: I have the following form in django forms.py class CtForm(ModelForm): class Meta: model = Contact fields = ["name", "email"] # widgets = {‘cid’: HiddenInput()} models.py class Contact(models.Model): cid = models.ForeignKey(Cr, on_delete=models.CASCADE) name = models.CharField(max_length=255, null=False) email = models.EmailField(max_length=255, null=False) I have the form displayed in a template, and …

Total answers: 1

anyone face this issue in django?

anyone face this issue in django? Question: enter image description here when i created a employee form and view the form it show like as image. <tr> <td>{{ form.employee_name.label }}</td> <td>{{ record.employee_name }}</td> </tr> <tr> <td>{{ form.dob.label }}</td> <td>{{ record.dob }}</td> </tr> <tr> <td>{{ form.age.label }}</td> <td>{{ form.age }}</td> </tr> only age field show like …

Total answers: 1

How to hide password field from request.user in django?

How to hide password field from request.user in django? Question: i am learning django currently and i have a question about request.user. I have made an custom user model and i use django’s built in authentication. When i use login function, everything works right. When i print request.user it returns the current user. When i …

Total answers: 1

Django not saving data with post

Django not saving data with post Question: I have this view: class TaskApiView(APIView): def post(self, request): serializer = TaskSerializer(data=request.data) print(request.data) if serializer.is_valid(): print("valid", serializer.data) serializer.save() return Response(status=status.HTTP_201_CREATED) else: print(serializer.errors) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) request body: { "content": "asd" } log: {‘content’: ‘asd’} valid {‘id’: 30} [21/Oct/2023 11:33:19] "POST /api/task/create HTTP/1.1" 201 0 But when I try …

Total answers: 1