That kind of table partitioning, usualy is made on the database level, not on the application level. You should check your database documentation to learn how implement that logic.
On PostgreSQL, check this <https://www.postgresql.org/docs/9.5/static/ddl-partitioning.html>. 2017-07-14 6:18 GMT-03:00 Christian Ledermann <christian.lederm...@gmail.com >: > What problem are you trying to solve and why this way? > How many rows does your table have? > What database are you using? > > On 13 July 2017 at 18:18, Kalvin Handilist <khandil...@gmail.com> wrote: > >> >> down votefavorite >> <https://stackoverflow.com/questions/45081886/django-multi-table-on-same-model#> >> >> I have huge table that needed to be sliced into some smaller table, ex: >> campaign_01, campaign_02, ... While using django queryset with different >> table name for same model, what I only know to set table name on a model >> is: Model._meta.db_table = 'tableXXX' >> >> However this method doesn't work in single shell/request. (only work for >> first time, but not for the next) -> maybe because it still on same >> instance? After the second time we tried to set _meta.db_table = >> 'tableYYY', it will occur an error "django.db.utils.ProgrammingError: >> missing FROM-clause entry for table "tableXXX"" >> >> I also have tried some suggestion I read for this problem answer like: >> >> class ListingManager(models.Manager): >> def get_custom_obj(self, table_name): >> self.model._meta.db_table = table_name >> return self >> class ObjectName(models.Model): >> objects = ListingManager() >> >> Try to create an Object manager to get new object, but it not work, it >> still throw same error as before (on the second time setting _meta.db_table) >> >> The only way to make it work if we want to set multiple times for >> _meta.db_table is we need to exit() the shell first, then re-enter the >> shell mode (which means for loop is not gonna work). >> >> I know it can be achieved with raw query 'Insert into tableXXX values >> ()', but any method to do it using django queryset? Thanks~ >> >> -- >> 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/ms >> gid/django-users/fba2ca9e-874f-45b8-b285-3c116fefb036%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/fba2ca9e-874f-45b8-b285-3c116fefb036%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Best Regards, > > Christian Ledermann > > Newark-on-Trent - UK > Mobile : +44 7474997517 <+44%207474%20997517> > > https://uk.linkedin.com/in/christianledermann > https://github.com/cleder/ > > > <*)))>{ > > If you save the living environment, the biodiversity that we have left, > you will also automatically save the physical environment, too. But If > you only save the physical environment, you will ultimately lose both. > > 1) Don’t drive species to extinction > > 2) Don’t destroy a habitat that species rely on. > > 3) Don’t change the climate in ways that will result in the above. > > }<(((*> > > -- > 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/CABCjzWpxwNiTQQ_urx3%2BkS%3DRKf_CNNUdOGg35LZ2N% > 2BzQMqLARA%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CABCjzWpxwNiTQQ_urx3%2BkS%3DRKf_CNNUdOGg35LZ2N%2BzQMqLARA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAOs3Lp4ROUC9-1epYC5V2JtiZ29m6v2bT_cBFCOfFgY7daO5hw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.