Setup - TaijaQ/Kudryavka GitHub Wiki

Instructions on how to install Kudryavka on your local computer, create a virtual environment, setup the Postgres database and configure Django so that you can quickly get started.

Contents

  1. Installation
  2. Configuration
    1. Environment variables
    2. Admin account
  3. Database
  4. Running the server

Installation

First, clone my project locally using git:

$ git clone [email protected]:TaijaQ/Kudryavka.git

Make sure you have Python installed. I use virtualenvwrapper to create a virtual environment for the project, you can install it with pip:

$ pip install virtualenvwrapper

Then create a new environment for your project in its directory, using the requirements file in my project to also automatically install the packages:

$ mkvirtualenv -r requirements.txt env_name

If you want to install the required packages by hand, you can also run:

(env_name) $ pip install -r requirements.txt

To activate the environment, type:

$ workon env_name

And stop working in the environment:

(env_name) $ deactivate

Configuration

We'll need to configure your settings before we can get to work.

Environment variables

There are a few envirnoment variables needed in the settings. The django-dotenv package supplies an implementation of dotenv for django. Create a file named .env in the project folder:

(env) $ nano .env

Then add these lines to it, filled with your own information:

SECRET_KEY='your_secret_key'
ACCESS_TOKEN=''
DEBUG=True
DATABASE_USER='user'
DATABASE_NAME='name'
USER_PASSWORD='password'
TIME_ZONE='Europe/Helsinki'

Since you don't ever run django-admin startproject, which will automatically add a randomly-generated SECRET_KEY to a project, you can get one with MiniWebTool's generator.

NOTE! Remember to add .env to your .gitignore file - don't commit it.

Admin account

You'll need to create a django superuser. Enter this command and it will ask for your information interactively:

(env_name) 4 ./manage.py createsuperuser

Database

We need to create a Postgres database. If you don't have it, install it.

We can use the command line tool to create the user and database. Run the following command:

$ psql

If the $ in your command line prompt has been replaced with #, you know you've succeeded. Create a user and the database with the following seperate commands:

CREATE USER name WITH PASSWORD 'password';
CREATE DATABASE db_name OWNER name;

Then add the user and database name to the settings file.

You will need to migrate the changes with this command:

(env_name) $ ./manage.py migrate

Running the server

In the project folder, run:

(env_name) $ ./manage.py runserver

Now you can visit the URL http://127.0.0.1:8000/, where you should see the Kudryavka project.

Up in the corner, there's the ADMIN link which will take you straight to the admin page (you can login with the superuser account). I recommend adding some project categories, projects and posts there first so you can see how the data looks on the main site.