JChao
JChao

Reputation: 2309

Django test -- Model object created but cannot be found

I'm calling a Model which is called People and do

People.objects.create(first='foo', last='bar', bio='test')

This Model uses db_table='"people"."background"'

When I run the test, doing People.objects.first() finds something, but doing raw query like SELECT * from people.background gives me nothing. Why is that?

Upvotes: 0

Views: 77

Answers (1)

JChao
JChao

Reputation: 2309

Apparently Django doesn't officially support schema.

I have come up with a workaround which connects to the db and makes a raw query directly. Essentially,

with connection().cursor as cursor:
    cursor.execute("""INSERT INTO bleh bleh bleh""")  # assuming there's autocommit

EDIT:

Django's response: Django doesn't officially support schemas. See #6148 for that. As far as I know, the . syntax only works on Oracle.

Upvotes: 1

Related Questions