openmeteo/enhydris

Cannot delete stations

aptiko opened this issue · 1 comments

aptiko commented

Attempting to delete a station on the admin usually fails, because it tries to warn about every single time series record.

aptiko commented

@muhammadahmadbwp To reproduce this, you need to attempt to delete a station that has a time series with data. I believe that the only one you have in your snapshot is "MEDAL: Rhodope". Here's how to do it:

First, ./manage.py dbshell and run the following:

delete from enhydris_synoptic_synoptictimeseriesgroup;
delete from enhydris_synoptic_synopticgroupstation;

(This "synoptic" functionality has nothing to do with what we're doing here but it's getting in the way.)

You also need to create an admin user with ./manage.py createsuperuser, which you have presumably already done since you have managed to delete stations.

Now go to station MEDSAL: Rhodope and try to delete it. Maybe it won't fail, but you will understand what the problem is: it warns you with a long list of related objects. Imagine if this list of related objects had a million entries. This is common.

I believe that Django has an option somewhere to not search for these related objects.