Skip to content

Commit

Permalink
Fatal error in 'Django: New Project' fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdevmanuel committed Mar 4, 2017
1 parent d1696f9 commit fd976c4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions django-commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ def get_executable(self):
version = self.settings.get("python_version")
return which(self.interpreter_versions[version])

def get_version(self):
binary = self.get_executable()
def get_version(self, extb=None):
if extb is None:
binary = self.get_executable()
else:
binary = extb
command = [binary, '-c', 'import django;print(django.get_version())']

try:
Expand All @@ -80,6 +83,7 @@ def find_manage_py(self):
django_project_root = \
sublime.active_window().active_view().settings().get('django_project_root') \
or self.settings.get('django_project_root')
print(django_project_root)
for path in [django_project_root] if django_project_root else sublime.active_window().folders():
for root, dirs, files in os.walk(path):
if 'manage.py' in files:
Expand Down Expand Up @@ -687,12 +691,14 @@ def set_interpreter(self, index):
name, self.interpreter = self.choices[index]
if name is not "default":
self.interpreter = os.path.join(self.interpreter, 'python')
if self.get_version(self.interpreter) == 0:
self.error_msg = "No module 'django' found in the selected environment"
self.display_error_message()
return
self.window.show_input_panel(
"Project name", "", self.check_folders, None, None)

def run(self):
if self.get_version() == 0:
return
venv_paths = self.settings.get("python_virtualenv_paths", [])
version = self.settings.get("python_version")
envs = self.find_virtualenvs(venv_paths)
Expand Down Expand Up @@ -720,6 +726,7 @@ def create_app(self, text):

def run(self):
if self.get_version() == 0:
self.display_error_message()
return
self.extra_args = list()
self.window.show_input_panel(
Expand Down

0 comments on commit fd976c4

Please sign in to comment.