diff --git a/Readme.md b/Readme.md index 275787d..50d9015 100644 --- a/Readme.md +++ b/Readme.md @@ -5,17 +5,17 @@ lostplaces-backend is a django (3.x) based webproject. It once wants to become a The software is currently in early development status, neither scope, datalmodel(s) nor features are finalized yet. Therefore we would not recommend to download or install this piece of software anywhere - except your local django dev server. ## Features -- manage lost places with lots of usefull information -- sensitive information is not accesiable for anonymous (not logged in) users -- user self registration using a voucher system, only people you invite can join your instance -- collaboration, every user can add informations like tags, photos and external links to your place +- Manage lost places with lots of usefull information. +- Sensitive information is not accesiable for anonymous (not logged in) users. +- User self registration using a voucher system, only people you invite can join your instance. +- Collaboration, every user can add informations like tags, photos and external links to your place. ## Dependencies Right now it depends on the following non-core Python 3 libraries. These can be installed using the package manager of your distribution or into the venv locally. - * [django](https://www.djangoproject.com/) django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. - * [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) A powerful, yet easy to implement thumbnailing application for Django 1.11+ - * [image](https://github.com/francescortiz/image) Image cropping for django + * [django](https://www.djangoproject.com/) is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. + * [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails) A powerful, yet easy to implement thumbnailing application for Django 1.11+. + * [image](https://github.com/francescortiz/image) Image cropping for django. * [django-widget-tweaks](https://github.com/jazzband/django-widget-tweaks) Tweak the form field rendering in templates, not in python-level form definitions. * [django-taggit](https://github.com/jazzband/django-taggit) A simpler approach to tagging with Django. @@ -48,42 +48,44 @@ $ pipenv shell ``` Visit: [admin](http://localhost:8000/admin) for administrative backend or -[frontend](http://localhost:8000/) +[frontend](http://localhost:8000/). + +Happy developing ;-) # Installing a productive instance Currently there are two ways to deploy the lostplaces project: -1. Cloning this repository, including the configured django instance -2. Install the package and setup the django instance your self +1. Cloning this repository, including the configured django instance. +2. Install the package and setup the django instance yourself. ## Cloning the repository -Essently, this is the same as installing an development instance, but without the development server (manage.py runserver) and something powerfull (Apache, NGINX) instead. You have to configure the webserve to work with the *SGI Api respectivly, reference [django's guide for deployment](https://docs.djangoproject.com/en/3.1/howto/deployment/) for further information. +Essentially, this is the same as installing a development instance, but without the development server (manage.py runserver) and something powerfull (Apache, NGINX) instead. You have to configure the webserve to work with the *SGI Api respectivly, reference [django's guide for deployment](https://docs.djangoproject.com/en/3.1/howto/deployment/) for further information. -You also should setup an dedicated database server, the build in SQLite file is not recommened for production use. Reference [django's guide for databases](https://docs.djangoproject.com/en/3.1/ref/databases/) for further information. +You also should setup a dedicated database server, the built-in SQLite file is not recommened for production use. Reference [django's guide for databases](https://docs.djangoproject.com/en/3.1/ref/databases/) for further information. Before making the django instance public, you should tweak the config `settings.py`: -1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)) -2. Turn off debug mode by setting `DEBUG = False` -3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/) +1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)). +2. Turn off debug mode by setting `DEBUG = False`. +3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/). -Run `lostplaces/managy.py collectstatic` you should be ready to go. +Run `lostplaces/managy.py collectstatic` and you should be ready to go. ## Installing the lostplaces_app to an existing django instance ### Installing django and the lostplaces app -If you haven't already setup an django instance, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/install/). +If you haven't already setup a django instance, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/install/). -After that, download the desired release (probably the latest one) [from the realeases page](https://git.mowoe.com/reverend/lostplaces-backend/releases) and install it using `pip install --user name-of-the-file.tar.gz`. +After that, download the desired release (probably the latest one) [from the realeases page](https://git.mowoe.com/reverend/lostplaces-backend/releases) and install it using `pip install --user name-of-the-file.tar.gz` -*Note: You can run pip install without the --user flag, which will require root privileges and introduces potential security issues* +*Note: You can run pip install without the --user flag, which will require root privileges and introduces potential security issues.* ### Configuring the django instance Now configure your `settings.py` as follows: -1. Add the following apps to the django project +1. Add the following apps to the django project. ```python INSTALLED_APPS = [ @@ -95,7 +97,7 @@ INSTALLED_APPS = [ ] ``` -2. Set the URL's and Root-directories for file handling, for example +2. Set the URL's and Root-directories for file handling, for example: ```python STATIC_URL = '/static/' @@ -105,13 +107,13 @@ MEDIA_URL = '/uploads/' MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') ``` -3. Set the user model (this will be changed in the next release) +3. Set the user model (this will be changed in the next release): ```python AUTH_USER_MODEL = 'lostplaces_app.Explorer' ``` -4. Set the URL's for login, for example +4. Set the URL's for login, for example: ```python LOGIN_URL = reverse_lazy('login') @@ -120,21 +122,19 @@ LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home') ``` ### Configuring the URL's -In the `urls.py` configure the `urlpatter` like this +In the `urls.py` configure the `urlpatter` like this: ```python urlpatterns = [ path('admin/', admin.site.urls), - path('signup/', SignUpView.as_view(), name='signup'), # If you want to use lostplaces sign up view - path('explorers/', include('django.contrib.auth.urls')), # You can change the 'explorers/' to whatever you desire - path('', include('lostplaces_app.urls')), # In this configuration lostplaces will be at the top level of you website, change '' to 'lostplaces/', if you don't want this -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # So django can deliver user uploaded files + path('signup/', SignUpView.as_view(), name='signup'), # If you want to use lostplaces' sign up view. + path('explorers/', include('django.contrib.auth.urls')), # You can change the 'explorers/' to whatever you desire. + path('', include('lostplaces_app.urls')), # In this configuration lostplaces will be at the top level of you website, change '' to 'lostplaces/', if you don't want this. +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # So django can deliver user uploaded files. ``` Before making the django instance public, you should tweak the config `settings.py`: -1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)) -2. Turn off debug mode by setting `DEBUG = False` -3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/) +1. Change the secret key, the one found in the config is already public. Choose something secure (i.e. [this](https://duckduckgo.com/?q=password+generator+64)). +2. Turn off debug mode by setting `DEBUG = False`. +3. Tune the localization settings, see [django's documentation](https://docs.djangoproject.com/en/3.1/topics/i18n/). Run `lostplaces/managy.py collectstatic` you should be ready to go. - -Happy developing ;-) diff --git a/lostplaces/lostplaces/settings.py b/lostplaces/lostplaces/settings.py index 23940fb..f02ff25 100644 --- a/lostplaces/lostplaces/settings.py +++ b/lostplaces/lostplaces/settings.py @@ -4,13 +4,16 @@ """ Django settings for lostplaces project. -Generated by 'django-admin startproject' using Django 3.0.8. +!!! Instead of changing this file, you can override settings in !!! +!!! local_settings.py. That way it won't cause merge conflicts on pull. !!! + +Generated by 'django-admin startproject' using Django 3.1.8. For more information on this file, see -https://docs.djangoproject.com/en/3.0/topics/settings/ +https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.0/ref/settings/ +https://docs.djangoproject.com/en/3.1/ref/settings/ """ import os @@ -21,7 +24,7 @@ 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/3.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'n$(bx8(^)*wz1ygn@-ekt7rl^1km*!_c+fwwjiua8m@-x_rpl0' @@ -79,7 +82,7 @@ WSGI_APPLICATION = 'lostplaces.wsgi.application' # Database -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { 'default': { @@ -90,7 +93,7 @@ DATABASES = { # Password validation -# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -109,7 +112,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/3.0/topics/i18n/ +# https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -123,7 +126,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.0/howto/static-files/ +# https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_files') @@ -135,3 +138,11 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') LOGIN_URL = reverse_lazy('login') LOGIN_REDIRECT_URL = reverse_lazy('lostplaces_home') LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home') + + +# Load and override settings from local_settings.py and don't fail on errors. + +try: + from .local_settings import * +except ImportError: + pass