openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
18 stars 11 forks source link

Cannot delete stations #492

Closed aptiko closed 1 year ago

aptiko commented 1 year ago

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

aptiko commented 1 year ago

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