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

215
Visualizações
How to implement an edit approval queue in Django

I am attempting to make it so a user can edit displayed info stored in an object but that edit is not displayed publicly until an admin approves the edit. These edits are stored in a queue that an admin can sort through. For example:

class examplemodel(models.Model):
    text = models.CharField()

This charfield is displayed on a template somewhere where a user can click a link, letting the text become a form containing the same info which when the form is submitted, sends the info not back into the database but to a queue to be approved on the admin page. The only way I can think to do this right now is to make a editRequest object that lets me have the form create a different object and then have some approval function that updates the old object if approved. In which case, how would I tie this to the admin page?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I would suggest to create a new model ApprovalPendingUsers with required fields and also add ForeignKey for user in that model. You can also add created_time and last_modified_time fields for sorting. When user submit edit form details store everything in your new model with user ForeignKey.

#import User Model
from apps.users.models import BaseUserModel 

class ApprovalPendingUsersModel (Models.Model):
    created_by = models.ForeignKey(BaseUserModel)
    # Other fields.

Create a list view for admin and return all rows of your new model to view.

class ApprovalPendingUsersListView(ListView):
    # template_name and context_object_name 

    def get_queryset(self):
        return ApprovalPendingUsersModel.objects.all()

When admin click on approval button replace BaseUserModel details with ApprovalPendingUsersModel and delete that row from ApprovalPendingUsersModel.

Use get_or_create to avoid creation of many ApprovalPendingUsersModel rows when user give more than one update requests.

about 4 years ago · Santiago Trujillo Relatório
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