Download the zip below.
Create a directory of where you want to start your project.
mkdir designtennis.com
cd designtennis.com
unzip ~/Downloads/base_xx.zip .
bash base/start.sh
During the install process it will prompt you to create a super user - you do you
After it's installed you can now run the server
source env/bin/activate
python application/manage.py runserver
In a new tab you should also run your grunt
grunt
Once it's been setup, remove the old base
rm -rf base_xx
PREV introduction
NEXT data types
In terminal:
$ cd /location/of/where/i/do/projects/
$ git init
$ git clone <paste project url from bitbucket>
$ cd project name
$ python2 -m venv env
$ source env/bin/activate
$ pip install req.txt
If the above does not work, make sure you have the right page_cms file in libs that corresponds to req.txt. If it still doesn't work, do the following:
$ pip install django
$ pip install page_cms…
$ pip install git+https://github.com/deschler/django-modeltranslation.git
then...
$ python application/manage.py makemigrations
$ python application/manage.py migrate
$ npm install grunt
Go to where you want to start your project in terminal
$ cd /location/of/where/i/do/projects/
$ mkdir <project name>
$ python3 -m venv env
$ source env/bin/activate
$ pip install page_cms...
$ pip install git+https://github.com/deschler/django-modeltranslation.git
$ django-admin startproject application
If django-admin doesn't work that means django wasn't install so
#### only do this if django didn't get installed...
$ pip install django
Inside of the of application/application/urls.py replace it with this code
from django.contrib import admin
from django.urls import path
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [ path('admin/', admin.site.urls), url(r'^', include('page_cms.urls')), ]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += i18n_patterns( url(r'^', include('page_cms.urls_all')), prefix_default_language=False )
Inside the settings file application/application/settings.py augment the information with the data bellow.
S3 = True#False
INSTALLED_APPS = [
'modeltranslation', #this needs to be at the top
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'page_cms', #this should be at the bottom
]
if S3:
INSTALLED_APPS += ['storages',]
Lower in the settings.py still...
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',
'django.middleware.locale.LocaleMiddleware',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, "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',
'django.template.context_processors.media',
'django.template.context_processors.static',
],
},
},
]
USE_I18N = True
STATICFILES_DIRS = (
"static",
os.path.join(BASE_DIR, "static"),
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "../public_html/static")
MEDIA_ROOT = os.path.join(BASE_DIR, '../public_html/media/')
MEDIA_URL = '/media/'
LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/admin/"
IMAGE_SMALL = 400
IMAGE_MEDIUM = 900
IMAGE_LARGE = 1900
Depending on the languages you want to support, usually it's just english but in this we show how to setup french and english.
gettext = lambda s: s
LANGUAGES = (
('en', gettext('English')),
('fr', gettext('French')),
)
MODELTRANSLATION_DEFAULT_LANGUAGE = 'en'
Get your keys and such from Amazon
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': '--------',
# 'USER': '--------',
# 'PASSWORD': '--------',
# 'HOST': '---------',
# 'PORT': '3306',
# }
# }
if S3:
AWS_ACCESS_KEY_ID = '------------'
AWS_SECRET_ACCESS_KEY = '-----------'
AWS_STORAGE_BUCKET_NAME = '--------'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
# AWS_S3_CUSTOM_DOMAIN = 'cdn.mydomain.com'
STATIC_URL = 'https://%s/%s/'%(AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
STATICFILES_STORAGE = '--------------------'
DEFAULT_FILE_STORAGE = '------------------' # <-- here is where we reference it
In terminal
$ python application/manage.py migrate
$ python application/manage.py createsuperuser
Create the template directory
$ mkdir /templates/
$ mkdir /templates/page_cms/
$ mkdir /templates/page_cms/page/
With this done you can now start creating your custom templates in the page folder you just made.
Usually we setup a base file that all the other files use for reference.
Create the base file /templates/base.html
<!DOCTYPE html><html>
<head>{% include "page_cms/meta.html" %}</head>
<body class="{% block page_class %}{% endblock page_class %}">
{% block nav %}
<nav>
<ul>
{% for link in navs.main_nav.links %}
<li><a href="{{link.link}}">{{link}}</a></li>
{% if link.sub_nav %}
<ul>
{% for sub_link in link.sub_nav.links %}
<li>
<a href="{{sub_link.link}}">{{sub_link}}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</ul>
</nav>
{% endblock nav %}
{% block content %}{% endblock content %}
{% include "page_cms/front-end.html" %}
</body></html>
Now this is the most basic version of the base file, you may need to add your own css, js, other meta tags.
{% include "page_cms/meta.html" %}
Includes quite a bit of content, so look at the meta tags added by this before adding your own.
{% for link in navs.main_nav.links %}
References a nav that is not created yet, but this type of error doesn't break the page.
Now you start creating your templates in /templates/page_cms/page/
The most basic template would look something like this
{% extends "base.html" %}
{% block page_class %}index_page{% endblock page_class %}
{% block content %}
<div class="wrapper">
<div data-slug="main_text"data-type="text">
{{main_text.text|safe}}
</div>
</div>
{% endblock content %}
There is a lot going on in the HTML (or liquid) above, we'll get into that as we describe the way PageCMS works on the next page.
Now you have a basic template that has a text editable field and can start creating pages!!!
PREV introduction
NEXT data types