Omar Gonzales
Omar Gonzales

Reputation: 4008

PyCharm: No manage.py file specified in Settings->Django Support after refactoring project name

How to configure Pycharm to detect manage.py correctly?

I've modified my project name perfectcushion to llama-stickers, using Pycharm IDE refactor -> rename.

However, now I get this error: No manage.py file specified in Settings->Django Support when trying to runserver from Pycharm IDE.

enter image description here

I also notice that the project is called: llama-stickers**[perfectcushion]**, why is there the old name of the project? Is there something I miss to refactor?

settings.py

"""
Django settings for llama-stickers project.

Generated by 'django-admin startproject' using Django 2.1.3.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

import os



# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^_67&#r+(c+%pu&n+a%&dmxql^i^_$0f69)mnhf@)zq-rbxe9z'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'shop',
    'search_app',
    'cart',
    'stripe',
    'order',
    'crispy_forms',

]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'llama-stickers.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'),
                 os.path.join(BASE_DIR, 'shop', 'templates/'),
                 os.path.join(BASE_DIR, 'search_app', 'templates/'),
                 os.path.join(BASE_DIR, 'cart', 'templates/'),
                 os.path.join(BASE_DIR, 'order', 'templates/'),]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'shop.context_processor.menu_links',
                'cart.context_processor.counter'
            ],
        },
    },
]

WSGI_APPLICATION = 'llama-stickers.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)


MEDIA_URL = '/media/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')


### Stripe Settings ###


STRIPE_PUBLISHABLE_KEY = 'pk_test_N0ksyIuO5d1ulLDuoMlLiU26'

STRIPE_SECRET_KEY = 'sk_test_fFHncrzOzBPS3XxDQM0TWMfy'

CRISPY_TEMPLATE_PACK = 'bootstrap4'

manage.py

#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'llama-stickers.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)

Upvotes: 1

Views: 4129

Answers (4)

Okello Marvin
Okello Marvin

Reputation: 101

I use intellij 2021 and the accepted answer was not applying to me. I found a solution by pressing Ctrl + Alt + Shift + S are pressed at the same time, then going to facets and pupulated the settings field which was empty hence causing the error. Click on the folder icon and select your settings file. enter image description here

Upvotes: 1

mechbaral
mechbaral

Reputation: 143

For those who are on mac click on edit scopes

enter image description here

Then add the respective path for

  • Project
  • Settings
  • Manage script

enter image description here

Upvotes: 0

Jeanpierre Rivas
Jeanpierre Rivas

Reputation: 282

Well how are you working with Pycharm

Go to > File > Settings> Languages & frameworks > Django

Here you configure your project.

configuration

Upvotes: 6

Omar Gonzales
Omar Gonzales

Reputation: 4008

So, I had to enter to the top Tool Bar and Edit Config of the Django Project there: See highlighted option.

enter image description here

En Enviroment you'll find:

PYTHONUNBUFFERED=1;DJANGO_SETTINGS_MODULE=perfectcushions.settings

Change that also to reflect your project's name:

PYTHONUNBUFFERED=1;DJANGO_SETTINGS_MODULE=llama-stickers.settings

Now I can runserver within terminal calling:

ogonz@ogonz:~/Escritorio/web_proyects/llama-stickers$ python manage.py runserver

However, cannot run manage.py directly with CTRL+ALT+R, inside PyCharm, still don't know why.

Upvotes: 1

Related Questions