Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install and use? #1

Open
tusharvb19 opened this issue Aug 11, 2018 · 1 comment
Open

How to install and use? #1

tusharvb19 opened this issue Aug 11, 2018 · 1 comment

Comments

@tusharvb19
Copy link

tusharvb19 commented Aug 11, 2018

Getting this error while compiling...

File "C:\Users\Sweet Home\Documents\dev\jetdemo\application\settings.py", line 37, in
SECRET_KEY = config.get('common', 'secret_key')
File "C:\Program Files\Python36\lib\configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "C:\Program Files\Python36\lib\configparser.py", line 1141, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'common'

Can anyone provide steps to run this demo on Django 2.1.0 ?

@imvickykumar999
Copy link

I also tried, and got same error, I know it's ChatGPT's answer, but it worked for me!

Install the Required Dependencies

cd requirements
pip install -r base.txt
pip install -r py3.txt

Here is the configuration file (config.ini) you can create to work with the given settings.py.

Steps to Create the Config File:

  1. Create a file named config.ini in the conf directory within your project's base directory.
  2. Populate it with the necessary sections and key-value pairs as shown below.

Example config.ini:

[common]
secret_key = your-secret-key-here
debug = True

[email]
server_email = [email protected]
host = smtp.example.com
port = 587
user = [email protected]
password = your-email-password
tls = True

[database]
ENGINE = django.db.backends.postgresql
NAME = jet_demo_db
USER = your-db-user
PASSWORD = your-db-password
HOST = localhost
PORT = 5432

Explanation of the Sections:

  1. [common]:

    • Stores the SECRET_KEY and DEBUG values.
    • Replace your-secret-key-here with a valid secret key (you can generate one using the command: django-admin startproject temp and copy its SECRET_KEY).
  2. [email]:

    • Configures the email backend for sending error notifications and other system emails.
    • Replace the placeholder values with your actual SMTP server details.
  3. [database]:

    • Configures the database connection.
    • Replace the placeholders with your database's credentials.
    • Example for PostgreSQL:
      • ENGINE: Use django.db.backends.postgresql for PostgreSQL. For MySQL, use django.db.backends.mysql.
      • NAME: Your database name.
      • USER: Database username.
      • PASSWORD: Database password.
      • HOST: Database host (use localhost if hosted locally).
      • PORT: Database port (default for PostgreSQL is 5432, for MySQL it's 3306).

Folder Structure:

Ensure your project structure includes the configuration file:

project/
├── application/
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
├── conf/
│   └── config.ini
├── manage.py

Final Steps:

  1. Run the Project:
    After creating the config.ini file, try running your Django project:

    python manage.py runserver
  2. Troubleshoot:

    • If the project still cannot find the configuration file, ensure the config.read(config_path) line in settings.py points to the correct config.ini file location.
    • Debug using print statements to verify config_path:
      print(config_path)
  3. Production Notes:

    • Set debug = False in the [common] section for production.
    • Use strong, secure credentials for SECRET_KEY, database, and email configurations.

Let me know if you need further assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants