2

I've installed existing Django project very 1st time and I've the problem with starting servers python manage.py runserver

Here it's what I've done

1.Clone the repo,

2.Make a virtual environment

3.Pip install requirements.txt

4.Generate access token and secret key and put in secrets.sh. I've the same SECRET_KEY in settings.py and secrets.sh and I've added secrets.sh to .gitignore

5.Change settings.py as follows:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'USER': 'name',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '',
    }
}

And I cannot run python manage.py migrate results below:

(tag_gen) local_user@local_user:~/Repo/tag_gen/generator$ python manage.py runserver
Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x7febe4712488>
Traceback (most recent call last):
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/local_user/Repo/tag_gen/generator/generator/urls.py", line 23, in <module>
    url(r'^etg/', include('generatorApp.urls', namespace='generatorApp')),
  File "/home/local_user/Repo/tag_gen/tag_gen/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/local_user/Repo/tag_gen/generator/generatorApp/urls.py", line 3, in <module>
    from . import views
  File "/home/local_user/Repo/tag_gen/generator/generatorApp/views.py", line 170
    def view_index(request: WSGIRequest):
                          ^
SyntaxError: invalid syntax

Ideas?

1
  • When using sqlite3 you can scrap all fields in DATABASES['default'] but ENGINE and NAME.
    – cezar
    Nov 9, 2017 at 10:49

2 Answers 2

6

The project you're trying to run is using Python ≥ 3.5, but you're trying to run it in 2.7.

The syntax (request: WSGIRequest): is a type hint. It was introduced a few years ago, but was only added to the newer versions of Python 3. No effort was made to support Python ≤ 3.4.

You'll need to look up instructions on how to create a virtualenv with a high enough version of Python. This changes based on operating system, so verbose instructions are probably out of scope for this question, but there is plenty of advice on the topic already.

1
  • Yup, you're right. I've prepared new venv and works. Thanks. Nov 9, 2017 at 12:04
0

1.Check python and django versions you have should be compatible with the installed requirements. if you have python version more than 3.+ run server with

python3 manage.py runserver

else if python version 2.7+

python manage.py runserver

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.