In my experience, the most reliable method is to ensure that user details required for order completion are stored in the order model before account deletion. I achieved this by overriding the user deletion process and using Django signals where appropriate, so that when a user initiates account removal, a dedicated function automatically replicates the necessary fields into the order record. This approach guarantees that order integrity remains intact without a persistent link to the user. It has proven more robust than attempting to maintain a foreign key after deletion since all vital data is securely duplicated.
hey guys, i solved it by copying user info to the order recrod pre-deletion via a custom signal. it’s a bit hacky but it avoids losing critical order data. any other better ideas?
Hey everyone, thanks for all the cool insights so far! I was mulling over this and though signals and detaching the foreign key are great, what about exploring a soft deletion approach for user accounts instead? Instead of wiping out the user record entirely, you could mark the account as inactive or archived. This way, you maintain the link between orders and users without actually keeping an active user account around. It might also simplify auditing and troubleshooting later on.
Alternatively, if your business rules insist on permanent deletion of user data, then having an archiving system either in the same table or even a separate table could be useful. This ensures that the original order retains the necessary info without keeping a live user object. Has anyone tried setting up such an archival system in Django? I’d love to hear if the extra complexity on the database side pays off in terms of maintaining integrity and performance over time.
What do you all think? Could soft deletion or a dedicated archive model be a more robust option, or do you think the signal-based approach is the way to go? Keen to know your experiences and any pitfalls you might have encountered with either method!
Hey everyone, interesting topic indeed! I was pondering on this and one approach that caught my attention was decoupling the transactional data from the user account completely. What if, before deleting the user, we have a process where the purchase record ‘seizes’ all necessary details from the user and then resets or nullifies the foreign key? This way, the order details remain intact, and we effectively lose the link with the user profile. I’m curious if anyone here has experimented with using Django signals to automatically clone the relevant user attributes into the order entry right before account deletion. Has anyone tried a similar method or maybe found some caveats when doing it this way? Let’s discuss!