mirror of
https://github.com/Balshgit/different
synced 2025-09-11 02:50:41 +03:00
add command and README.md
This commit is contained in:
parent
3f14070560
commit
bef1e8a9f1
61
django_accounts_app/README.md
Normal file
61
django_accounts_app/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
# Installation
|
||||
|
||||
##*Add to settings.py*
|
||||
|
||||
LOGIN_REDIRECT_URL = '/admin/'
|
||||
LOGOUT_REDIRECT_URL = '/accounts/login/'
|
||||
|
||||
To INSTALLED_APPS
|
||||
|
||||
'server.apps.accounts',
|
||||
|
||||
Email settings
|
||||
|
||||
```
|
||||
from server.settings.components import config
|
||||
|
||||
ACCOUNT_ACTIVATION_DAYS = 2
|
||||
EMAIL_TIMEOUT = 20
|
||||
|
||||
EMAIL_HOST = config('EMAIL_HOST')
|
||||
EMAIL_PORT = config('EMAIL_PORT', cast=int)
|
||||
EMAIL_USE_SSL = config('EMAIL_USE_SSL', cast=bool)
|
||||
EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool)
|
||||
|
||||
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
|
||||
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
|
||||
|
||||
# Is used to set sender name
|
||||
# https://docs.djangoproject.com/en/1.11/ref/settings/#default-from-email
|
||||
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
|
||||
SERVER_EMAIL = EMAIL_HOST_USER
|
||||
```
|
||||
|
||||
## Add to templates
|
||||
|
||||
to base.html
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
||||
## Add to .env
|
||||
|
||||
```
|
||||
# ====== Email settings =====
|
||||
|
||||
EMAIL_HOST=
|
||||
EMAIL_HOST_USER=
|
||||
EMAIL_HOST_PASSWORD=
|
||||
EMAIL_PORT=
|
||||
EMAIL_USE_SSL=
|
||||
EMAIL_USE_TLS=
|
||||
```
|
||||
|
||||
## To urls.py
|
||||
|
||||
from health_check import urls as health_urls
|
||||
|
||||
url_patterns
|
||||
|
||||
path('accounts/', include(accounts_urls)),
|
||||
|
19
django_accounts_app/management/commands/create_superuser.py
Normal file
19
django_accounts_app/management/commands/create_superuser.py
Normal file
@ -0,0 +1,19 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from server.apps.accounts.models import CustomUser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if not CustomUser.objects.filter(username='admin').exists():
|
||||
username = 'admin'
|
||||
email = 'admin@admin.ru'
|
||||
password = 'admin'
|
||||
admin = CustomUser.objects.create_superuser(username=username,
|
||||
password=password,
|
||||
email=email)
|
||||
admin.is_active = True
|
||||
admin.is_admin = True
|
||||
admin.save()
|
||||
else:
|
||||
print('Admin accounts can only be initialized if no Accounts exist')
|
Loading…
x
Reference in New Issue
Block a user