Skip to content
Advertisement

Tag: django

Django: How to mangle through relations

I have an instance of ModelA and want to query all instances of ModelC which are related to ModelA through ModelB. ModelA -> all ModelB instances with FK rel_a = ModelA -> rel_c.all() I know how I would do this in SQL but I really do not get how I should unmangle these relations Answer You can query with a

Double quotes problems with Postgres

I am using Django with postgres. Here’s the snippet of my code which I am using to create tables in the db. My question is: why is the user table getting renamed as “user” (with quotes) why is the role_id getting named as role_id_id where as I have clearly mentioned role_id to be my column name? Answer After reading few

How to fix traffic session table doesn’t exists error?

When I try to execute my code,I am getting this error? How could I resolve this issue? Answer I don’t know if you wrote this POST request or if it is a library or something. Could you please provide more info about it? As the error describes, it seems that: Make sure this table exists and it is available at

Two foreign keys, only one can be not null at a time

I have a database table with two foreign keys pointing to two different tables. The business logic requires an “either or” relationship; only one foreign key can be NOT NULL at any given time. Here are the four possible states the foreign keys can hold based on the business logic: NULL, NULL – okay number, NULL – okay NULL, number

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

Advertisement