Commit 5d8b0571 authored by Giorgos Kazelidis's avatar Giorgos Kazelidis

Initial commit

parents
# backup files
*~
*.bak
# Python compiled bytecode files
*.pyc
# virtual environment folder
venv/
#### ENVIRONMENT SPECIFICATIONS
* Working OS: Ubuntu 16.04 LTS
* Python version: 3.5.2 (pre-installed)
* Git version: 2.7.4
* pip version: 8.1.1
* virtualenv version: 15.2.0
* Django version: 2.0.4
* MySQL server version: 5.7.22
---
#### DOWNLOADING THE PROJECT & SETTING UP THE ENVIRONMENT
(A) install pip3 (`pip3 --version` to see if it is already installed):
sudo apt-get install python3-pip
(B) install virtualenv (`virtualenv --version` to see if it is already installed):
pip3 install virtualenv
(C\) install and configure Git [sources:
       -- "How To Install Git with Apt" and "How To Set Up Git" sections of https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-16-04
       -- https://www.tutorialspoint.com/git/git_environment.htm
       ]:
       (1) install Git (`git --version` to see if it is already installed):
sudo apt-get install git
       (2) set the Git "name" and "email" global parameters (`git config --list` to see if they have already been set):
git config --global user.name "YOUR_NAME"
git config --global user.email "YOUR_EMAIL"
(D) create a local instance of the remote repository (userbase):
       (1) navigate to Desktop:
cd ~/Desktop
       (2) clone the repository to create the corresponding instance locally:
git clone https://git.softlab.ntua.gr/giorgkazelidis/userbase.git
       (3) navigate to the local instance:
cd userbase
(E) install Django and MySQL inside the local instance using virtualenv with Python 3 [sources:
       -- steps 2 and 3 of https://help.dreamhost.com/hc/en-us/articles/215317948-How-to-install-Django-using-virtualenv
       -- step 3 of https://www.digitalocean.com/community/tutorials/how-to-create-a-django-app-and-connect-it-to-a-database
       -- end of section http://docs.python-guide.org/en/latest/dev/virtualenvs/#lower-level-virtualenv
       -- https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04
       -- "Create a MySQL Database" section of http://www.marinamele.com/taskbuster-django-tutorial/install-and-configure-mysql-for-django
       -- https://www.tutorialspoint.com/django/django_admin_interface.htm
       ]:
       (1) specify the full file path (/usr/bin/python3) to the installed Python version:
which python3
       (2) create the virtual environment (venv) and specify the desired Python version to be used:
virtualenv ~/Desktop/userbase/venv -p /usr/bin/python3
       (3) activate the virtual environment:
source venv/bin/activate
       (4) install necessary Python and MySQL development headers and libraries (if you have not already done so):
sudo apt-get install python3-dev libmysqlclient-dev
       (5) install appropriate versions of virtual-environment-specific packages:
pip install -r requirements.txt
             ALTERNATIVELY, you could install the packages (Django and MySQL Database Connector - mysqlclient) individually by typing the following:
pip install Django==2.0.4
pip install mysqlclient
       (6) install MySQL server (`mysql --version` to see if it is already installed):
              * WARNING: while installing MySQL server, you will be asked to set the password for the root user.
sudo apt-get install mysql-server
mysql_secure_installation
       (7) use the password that was set for the root user during MySQL server installation as the 'PASSWORD' value of the 'default' dictionary of the DATABASES dictionary in **~/Desktop/userbase/myprj/myprj/settings.py**
       (8) if you have not created the project database (usermergeDB) yet, open MySQL console with root privileges (you should provide the password that was set for the root user during MySQL server installation), create the project database and exit MySQL console:
mysql -u root -p (ALTERNATIVELY: python manage.py dbshell)
CREATE DATABASE usermergeDB;
EXIT;
       (9) initiate the database:
python manage.py migrate
       (10) deactivate the virtual environment:
deactivate
---
#### UPDATING THE PROJECT
Provided you have already downloaded the (source code of the) project (that is, you have followed the steps of the "DOWNLOADING THE PROJECT & SETTING UP THE ENVIRONMENT" section above), the recommended steps to update the (source code of the) project are:
       (1) delete the local instance of the remote repository (userbase) as well as the virtual environment:
rm -rf ~/Desktop/userbase
       (2) follow steps (D) and (E) of the "DOWNLOADING THE PROJECT & SETTING UP THE ENVIRONMENT" section above
---
#### RUNNING THE PROJECT (INSIDE THE VIRTUAL ENVIRONMENT):
(A) activate the virtual environment:
cd ~/Desktop/userbase
source venv/bin/activate
(B) navigate to the project directory (myprj):
cd myprj
(C\) start the Django development server (at http://127.0.0.1:8000/):
python manage.py runserver
(D) navigate to http://127.0.0.1:8000/ via web browser to run the project
---
#### STOPPING THE PROJECT (AND EXITING THE VIRTUAL ENVIRONMENT):
(A) stop the Django development server (running at http://127.0.0.1:8000/):
       -- return to the terminal where you have run `python manage.py runserver` and press "Ctrl-C"
(B) deactivate the virtual environment:
deactivate
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myprj.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)
"""
Django settings for myprj project.
Generated by 'django-admin startproject' using Django 2.0.4.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/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.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '9ni0eujs0@5d$1+a5hm+o&%7y(w^&(&o9gr5$4c&i3ow%sttjf'
# 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',
'usermerge',
]
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 = 'myprj.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
WSGI_APPLICATION = 'myprj.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
# https://docs.djangoproject.com/en/2.0/ref/databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'usermergeDB',
'USER': 'root',
'PASSWORD': 'SET_ROOT_PASSWORD_HERE',
'HOST': '',
'PORT': '',
'OPTIONS': {
'init_command': "SET default_storage_engine=INNODB;" \
"SET sql_mode='STRICT_TRANS_TABLES'",
},
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/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.0/topics/i18n/
LANGUAGE_CODE = 'el-gr'
TIME_ZONE = 'Europe/Athens'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
"""myprj URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
"""
WSGI config for myprj project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myprj.settings")
application = get_wsgi_application()
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class UsermergeConfig(AppConfig):
name = 'usermerge'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment