The next series of posts will deal with steps I’ve taken to prevent deleting past playlists. I’ve even gone to the lengths of disabled deleting PlayHistory
at the database level. So what do we do when we need to delete an artist? Answer: we don’t.
If an artist has made it into the system, we should only delete it if it is a duplicate of some sort. Perhaps a misspelling. So we don’t actually want to delete it, we want to merge it with the correct spelling. There are many things that can only be done in the Admin interface. Mostly it’s things that only the managers can do, like set up the rotation schedule or user management. I’ve decided that deleting artists should be one of them.
The first step is to change the “Delete” link on the change form to “Merge with duplicate”. Unfortunately, it’s not as simple as it should be. The actual template with the word “Delete” is submit_line.html
. And it’s not something that can be changed. In the ModelAdmin
, we add change_form_template = 'dj_pro/admin/change_form.html'
since that’s as close as we can get. It’s a copy of the original change_form.html
with {% submit_row %}
changed to {% include "dj_pro/admin/submit_line.html" %}
. submit_row
is an overly complex template tag that I just omitted for simplicity. My submit_line.html
is also stripped to just the HTML I want. The save_as
option just won’t work at all now.
Next time I’ll talk about writing the actual merge function. It’s quite long and involved.