searcher__dm01
searcher__dm01

Reputation: 129

Problems filtering columns that have many rows with a None value(Django database)

I am filtering a certain column in PostgreSQL database.

 n = Database.objects.values(column).count()
        for i in range(0, n):
            name = list(Database.objects.all().values_list(column, flat=True))[i]

There are 105 lines. From line 86 onwards the values are None. However, when querying line 43, the returned value is None, although in the database this line is filled with a value.

Strangely, when I populate lines 86 onwards, the query on line 43 is correct and does not return a None value.

I want to know if there is any problem when filtering columns that have many None values and why this might be happening

Upvotes: 0

Views: 16

Answers (1)

J_H
J_H

Reputation: 20450

I want to know if there is any problem when filtering columns that have many None values

No, there is no problem with that.


A relational database contains sets of rows, named "tables".

Sets are unordered. Yet you speak of values starting at this or that offset, as though we had a list of values where order matters.

I recommend that you order your result rows so they appear in a reproducible sequence. Use ORDER BY with the database, and sorted( ... ) for python expressions.

Upvotes: 1

Related Questions