Check if that is not something you're looking for: https://docs.djangoproject.com/en/1.5/ref/signals/#post-syncdb
On Wednesday, December 25, 2013 7:18:45 PM UTC, [email protected] wrote: > > I have an actions.py file which defines custom actions for the admin page > for one of my models. It uses an intermediary page (like the default delete > action) and hence has a corresponding form which is also declared in the > same file. > > For some reason, I had drop by database (development) and now when I try > to run syncdb, it gives me the following error: > > > Traceback (most recent call last): > File "/home/vinayak/pyCharm/helpers/pycharm/django_manage.py", line 23, > in <module> > run_module(manage_file, None, '__main__', True) > File "/usr/lib/python2.7/runpy.py", line 176, in run_module > fname, loader, pkg_name) > File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code > mod_name, mod_fname, mod_loader, pkg_name) > File "/usr/lib/python2.7/runpy.py", line 72, in _run_code > exec code in run_globals > File "/home/vinayak/zenatix/customuser/manage.py", line 10, in <module> > execute_from_command_line(sys.argv) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 399, in execute_from_command_line > utility.execute() > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 392, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", > line 242, in run_from_argv > self.execute(*args, **options.__dict__) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", > line 284, in execute > self.validate() > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", > line 310, in validate > num_errors = get_validation_errors(s, app) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", > > line 34, in get_validation_errors > for (app_name, error) in get_app_errors().items(): > File > "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line > 196, in get_app_errors > self._populate() > File > "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line > 75, in _populate > self.load_app(app_name, True) > File > "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line > 99, in load_app > models = import_module('%s.models' % app_name) > File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", > line 40, in import_module > __import__(name) > File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/models.py", > line 63, in <module> > patch_root_urlconf() > File "/usr/local/lib/python2.7/dist-packages/debug_toolbar/models.py", > line 51, in patch_root_urlconf > reverse('djdt:render_panel') > File > "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line > 480, in reverse > app_list = resolver.app_dict[ns] > File > "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line > 310, in app_dict > self._populate() > File > "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line > 262, in _populate > for pattern in reversed(self.url_patterns): > File > "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line > 346, in url_patterns > patterns = getattr(self.urlconf_module, "urlpatterns", > self.urlconf_module) > File > "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line > 341, in urlconf_module > self._urlconf_module = import_module(self.urlconf_name) > File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", > line 40, in import_module > __import__(name) > File "/home/vinayak/zenatix/customuser/customuser/urls.py", line 6, in > <module> > admin.autodiscover() > File > "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", > line 29, in autodiscover > import_module('%s.admin' % app) > File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", > line 40, in import_module > __import__(name) > File "/home/vinayak/zenatix/customuser/iiitd/admin.py", line 3, in > <module> > from actions import grant_read_permission > File "/home/vinayak/zenatix/customuser/iiitd/actions.py", line 13, in > <module> > class SelectUserForm(forms.Form): > File "/home/vinayak/zenatix/customuser/iiitd/actions.py", line 16, in > SelectUserForm > clientObj = ClientInfo.objects.all()[:1].get() > File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", > line 301, in get > num = len(clone) > File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", > line 77, in __len__ > self._fetch_all() > File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", > line 854, in _fetch_all > self._result_cache = list(self.iterator()) > File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", > line 220, in iterator > for row in compiler.results_iter(): > File > "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", > line 710, in results_iter > for rows in self.execute_sql(MULTI): > File > "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", > line 781, in execute_sql > cursor.execute(sql, params) > File > "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line > 69, in execute > return super(CursorDebugWrapper, self).execute(sql, params) > File > "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line > 53, in execute > return self.cursor.execute(sql, params) > File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line > 99, in __exit__ > six.reraise(dj_exc_type, dj_exc_value, traceback) > File > "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line > 53, in execute > return self.cursor.execute(sql, params) > django.db.utils.ProgrammingError: relation "iiitd_clientinfo" does not > exist > LINE 1: ...ientinfo"."id", "iiitd_clientinfo"."corp_id" FROM "iiitd_cli... > > > iiitd is the name of one of my apps. The reason this is happening is > because actions.py imports the iiitd_clientinfo model - but that doesn't > exist yet, obviously. Currently, I make it work by excluding/commenting out > my actions.py file. Surely, there has to be a work around? > > I have tried the following: > > 1. south migration before syncdb - same error. > 2. sorted out the INSTALLED_APPS order to ensure that they are in a > topological order - same error > 3. Used this in my actions.py: > > try: > > clientObj = ClientInfo.objects.all()[:1].get() > > except ClientInfo.DoesNotExist: > > clientObj = None > > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8f6bb497-9e1f-44ac-b372-2c366b1abbb1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.

