Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda