Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
django how to delete query object from template

how can I perform an object delete from queryset when I click some button in template for django view

here is my code ...

HTML enter image description here

views.py

def CamerasList(request):
model = Cameras
# This function can hadle both the retrieval of the view, as well as the submission of the form on the view.
if request.method == 'POST':
    form = CamerasForm(request.POST, request.FILES)
    if form.is_valid():
        form.delete_cam_id = request.POST.get('delete_cam_id')
        deletelement = Cameras.objects.get(pk=form.delete_cam_id)
        deletelement.delete()

var = {}
var = user_group_validation(request)
theuser = request.user
theuserid = Users.objects.get(user_id=theuser.id).pk
theorgid = Users.objects.get(pk=theuserid).organization_id.pk

if var['grupo'] == 'superuser':
    object_list = Cameras.objects.all()
    organization = Organizations.objects.all()
    url = request.session['url']
if var['grupo'] == 'admin' or var['grupo'] == 'user':
    object_list = Cameras.objects.filter(organization_id=request.session['userInc'])
    organization = Organizations.objects.filter(id=request.session['userInc'])
    url = request.session['url']

template = get_template(app+u'/cameras_list.html')
return HttpResponse(template.render(locals()))
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!