D
D
Dmitry Sviridov2021-08-28 11:07:57
Django
Dmitry Sviridov, 2021-08-28 11:07:57

How to remove duplicates in Django?

I have a model with fields area (region), city (city), district (district). There are other fields, but we are not talking about them. How to correctly select all records from the table that are unique in these three fields (what the id value will be is not important to me)? .values('area', 'city', 'district').distinct() doesn't work because I need all the columns of the table, not just those listed in values. Maybe you can somehow group by these 3 fields, but without annotate (because I don't need aggregation)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mkone112, 2021-08-28
@mkone112

Can use a bunch of values ​​and annotate?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question