Skip to content

Tag: django

Django Reverse Regex Match

I have a table (Django Model) and each row/object contains a regular expression that I should evaluate over a given input to filter relevant objects. Is there any Django ORM method to do this? In Postgre it will be: and the opposite of what I am searching for is: I know that evaluating the regular expressions on the application side

Django many-to-many: Best way to get elements in one related query set but exclude elements in other related query sets?

Consider these related models: In a view, I need to query to get all Bs related to a given A while excluding all Bs related with a set of other As. I need the grey area: My current, grossly inefficient approach is as follows: In my application, previous_As could have nearly 1,000 elements, which makes this approach extremely expensive. Is

Subquery django query to get biggest disctint values from objects and return those objects

So I have this query that I need to re-filter to get just the biggest taken_at field’s value from distinct meter id, but I cannot get the django orm’s/sql part to makes this query. <QuerySet [<Reading: [127] meter installation: 29, type: 1, taken: 2019-10-07 16:06:48.101453+00:00 value: 78.0000, comment: , VAT: 22.00>, <Reading: [126] meter installation: 41, type: 2, taken: 2019-10-07