skip to Main Content

Postgresql – How to annotate django queryest using subquery where that subquery returns list of ids from related model records

I have one database model, let's say ModelA: class ModelA(models.Model): field_1 = models.ManyToManyField( "core.ModelB", blank=True ) user = models.ForeignKey("core.User", on_delete=models.CASCADE) type = models.CharField(choices=ModelATypes.choices) The field_1 of ModelA is a many to many field that references ModelB. class ModelB(models.Model): uid =…

VIEW QUESTION

Html – JS Appended Array in FomData not accessable in Django backend

In a django template i have this js script: const formData = new FormData(form); formData.append('taglist', JSON.stringify(selectedTagIds)); console.log(JSON.parse(formData.get('taglist'))) console.log(formData.get('title_raw')) form.submit() selectedTagIds is an array. The console logs it correctly. After submitting I can access every standard form field in the django…

VIEW QUESTION

Javascript – Django 'none' values from ajax

My views: def deleteDepartement(request): object_id = request.POST.get('Id') name= request.POST.get('name') print(object_id) print(name) try: D=Department.objects.get(id=object_id) except: print("NOT FOUND") return redirect('department') JavaScript code: $.ajax({ type: 'POST', url: "{% url 'deleteDepartement' %}", data: { csrfmiddlewaretoken: '{{ csrf_token }}', Id:objectId, name:'test', }, }); I got…

VIEW QUESTION
Back To Top
Search