Hi, On Friday 06 January 2017 10:29:34 felipe.pereira.nit...@gmail.com wrote: > I'm working with Django 1.9.7 with Postgresql and I stuck in a problem > with relations between tables in different schemas. > > The problem that I'm facing is that I have a table, for example, named > *product, *which is in a schema named *dataflex *and another table > named *client_product_sale_stc *in another schema. > When I try to migrate a relation between *client_product_sale_stc *and > *product, *I got this error: > > django.db.utils.ProgrammingError: ERRO: syntax error at or near > "dataflex" LINE 1: ...CONSTRAINT > "client_product_setor_id_52aad07a_fk_"dataflex".... > > > After sometime trying to figure It out a solution for this problem, I > tried to change the schemas's name to just df instead of dataflex and > It worked perfectly. > > I also tried to decreased table's name, and It worked just like when I > decreased schema's name size, so this It seems to be a problem with > big constraints names. > > > I'm using the follow syntax: > > *db_table = '"dataflex"."product"'*
Django has no support for database schema's and a bit of duckducking would've shown you that. For example this ticket[1] shows that it may or may not be coming in Django 2.0, but almost certainly not in a 1.x release. So, any errors caused by you trying to work around it, are on you and when the implementation *does* land in 2.0, you'll be stuck with your work arounds. Think hard about that before trying to go that route. Now, there's one app[2] I know of that does use the PostgreSQL schema support, but implemented at the project level, not on a table level and for a specific purpose. And finally, there's this approach[3], where you'd have to write the routing yourself - trivial to do and when done correctly should be easy to refactor to any solution Django comes up with in future releases. In no way, should you mess with official Django model properties to trick the ORM - as you are now seeing that goes down the wrong path. -- Melvyn Sopacua -------- [1] https://code.djangoproject.com/ticket/6148 [2] https://pypi.python.org/pypi/django-tenant-schemas [3] https://www.amvtek.com/blog/posts/2014/Jun/13/accessing-multiple-postgres-schemas-from-django/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1709089.Y4ztckzY5a%40devstation. For more options, visit https://groups.google.com/d/optout.