Django commands cron ImportError: cannot import name -


i want add models commands. /home/max/askmoiseev/ask/management/commands/cron.py

# -*- coding: utf-8 -*-  django.core.management.base import basecommand, commanderror ask.models import tag   class command(basecommand):      def handle(self, *args, **options):         print args 

$ python manage.py cron

traceback (most recent call last):   file "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/__init__.py", line 272, in fetch_command klass = load_command_class(app_name, subcommand)   file "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 75, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name))   file "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module __import__(name)   file "/home/max/askmoiseev/ask/management/commands/cron.py", line 4, in <module> ask.models import tag   file "/home/max/askmoiseev/ask/models.py", line 3, in <module> loginsys.models import user   file "/home/max/askmoiseev/loginsys/__init__.py", line 3, in <module> ask.models import user importerror: cannot import name user 

what's problem? tried so:

#!/bin/bash export django_settings_module=askmoiseev.settings ./manage.py cron 

but did not help.

the below should work. must make sure python/django package askmoiseev importable. make importable simplest way set current working directory directory on package askmoiseev exists.

import os os.environ['django_settings_module'] = 'askmoiseev.settings' ask.models import tag 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -