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_modulefname, loader, pkg_name)File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_codemod_name, mod_fname, mod_loader, pkg_name)File "/usr/lib/python2.7/runpy.py", line 72, in _run_codeexec code in run_globalsFile "/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_lineutility.execute()File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in executeself.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_argvself.execute(*args, **options.__dict__)File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 284, in executeself.validate()File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 310, in validatenum_errors = get_validation_errors(s, app)File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 34, in get_validation_errorsfor (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_errorsself._populate()File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 75, in _populateself.load_app(app_name, True)File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 99, in load_appmodels = 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_urlconfreverse('djdt:render_panel')File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 480, in reverseapp_list = resolver.app_dict[ns]File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 310, in app_dictself._populate()File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 262, in _populatefor pattern in reversed(self.url_patterns):File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 346, in url_patternspatterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 341, in urlconf_moduleself._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 autodiscoverimport_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_permissionFile "/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 SelectUserFormclientObj = ClientInfo.objects.all()[:1].get()File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 301, in getnum = 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_allself._result_cache = list(self.iterator())File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iteratorfor row in compiler.results_iter():File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 710, in results_iterfor rows in self.execute_sql(MULTI):File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 781, in execute_sqlcursor.execute(sql, params)File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 69, in executereturn super(CursorDebugWrapper, self).execute(sql, params)File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in executereturn 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 executereturn self.cursor.execute(sql, params)django.db.utils.ProgrammingError: relation "iiitd_clientinfo" does not existLINE 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:
- south migration before syncdb - same error.
- sorted out the INSTALLED_APPS order to ensure that they are in a topological order - same error
- 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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/44eb9b23-bc9c-4f26-91e7-cf60c0faf839%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment