Zagorodniy Olexiy
Zagorodniy Olexiy

Reputation: 2212

Errors when trying to create new project or create new app in existing project

On my server is Django 1.9, several months ago i updated it from Django 1.8. And everything works fine until i decided to create new app in existing project:

python manage.py startapp test123

Then i got an error:

/test123/tests.py already exists, overlaying a project or app into an existing directory won't replace conflicting files

So I tried to do this on another projects and still the same. Then I tried to create new project and install new app on it, but when i type this command:

django-admin.py startproject anyproject

I got this error: CommandError: /var/www/anyproject/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files Then i type this command in the root of existing project:

django-admin runserver

End got error:

Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2749, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 446, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 459, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 628, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: Django==1.8.3

Then this command:

django-admin.py runserver

Then there was this error:

 File "/usr/local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, 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 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 39, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 16, in <module>
    from django.db.migrations.executor import MigrationExecutor
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 7, in <module>
    from .loader import MigrationLoader
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 12, in <module>
    class MigrationRecorder(object):
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 26, in MigrationRecorder
    class Migration(models.Model):
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 27, in Migration
    app = models.CharField(max_length=255)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1072, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 166, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 55, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

After that i uninstall all Django using pip, and then install again. But i still have this errors. Can anybody help me with it? Thanks

Upvotes: 0

Views: 575

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599580

The command to start a new app is startapp, not startproject. startproject is, well, for starting a completely new project, with a new manage.py etc; obviously if you already have a project, you don't want to overwrite those files.

And to run the server - or do anything once the project has been created - you should always use manage.py (or pass the --settings parameter to django-admin, which is effectively what manage.py does).

Upvotes: 1

Related Questions