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?
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.