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: 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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@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/fba2ca9e-874f-45b8-b285-3c116fefb036%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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.
class LocationAdmin(geo_admin.OSMGeoAdmin):
form = LocationForm
map_template = 'gis/admin/google.html
In my settings.py I have added my folder:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.static',
],
'debug': DEBUG
},
}
]and my files are properly located:However, when my admin page loads, it seems to not load from my template but instead load from django/forms/templates/ (as per error).Template-loader postmortem
Django tried loading these templates, in this order:
Using engine
django:
django.template.loaders.filesystem.Loader: ***/lib/python2.7/site-packages/django/forms/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/django/contrib/auth/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/django/forms/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/filebrowser/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/django/contrib/admin/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/django/contrib/gis/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/tinymce/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/ios_notifications/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/adminsortable/templates/gis/admin/google.html (Source does not exist)django.template.loaders.app_directories.Loader: ***/lib/python2.7/site-packages/django_mptt_admin/templates/gis/admin/google.html (Source does not exist)Any idea why it is not picking up, and is there any way to overwrite the map widget (or any other widgets for the matter)?Thanks.Regards,Kok Hoor