Giter VIP home page Giter VIP logo

djangoblog's Introduction

Django Blog

About

Блог на основе Django framework

Реализовано

Админ панель Post модель для блога Комментарии Статические страницы Теги ЧПУ (site/frendly_link/) Карта сайта (sitemap.xml) Отправка email

Install

  1. Создайте базу в PostgreSQL
  2. Add the pg_trgm module to the database
    CREATE EXTENSION pg_trgm;
  3. Создайте виртуальное окружение
  4. Установите зависимости из requirements.txt
    pip install -r requirements.txt
  5. Создайте проект Django и скопируйте в него папку blog
  6. Отредактируйте settyngs.py
import os

# Загрузка переменных окружения
from dotenv import load_dotenv
load_dotenv(verbose=True)

INSTALLED_APPS = [
	...
	'django.contrib.sites',
    'django.contrib.sitemaps',
    'martor',
    'crispy_forms',
    'blog',
    'django.contrib.admin', # переместить в конец
]

...

TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")
TEMPLATES = [
    {
    	...
        'DIRS': [TEMPLATE_DIR],
       	...
    },
]

...

DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.postgresql_psycopg2',
 'NAME': 'BASE_NAME',
 'USER': 'BASE_USER',
 'PASSWORD': 'BASE_PASSWORD',
 'HOST': 'localhost',
 'PORT': '',
 }
}

...

LOGIN_REDIRECT_URL = '/'

# lang
LANGUAGE_CODE = 'ru-ru'
USE_I18N = True
USE_L10N = False

# time
USE_TZ = True
TIME_ZONE = 'UTC'
DATE_FORMAT = 'd E Y'

# email (yandex.ru)
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_PORT = 465
EMAIL_HOST_USER = "[email protected]"
EMAIL_HOST_PASSWORD = "YOUR_PASSWORD"
EMAIL_USE_SSL = True
SERVER_EMAIL = EMAIL_HOST_USER
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

# time
USE_TZ = True
TIME_ZONE = 'UTC'
DATE_FORMAT = 'd E Y'

# static files
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static_prod")

# media files
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  1. Отредактируйте основной url.py
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('blog.urls')),
    path('martor/', include('martor.urls')),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  1. Перейдите в папку проекта и выполните следующие команды:
manage.py migrate
manage.py createsuperuser
manage.py makemigrations blog
manage.py migrate blog
  1. Запускаем сервер.
manage.py runserver
  1. Открываем в браузере http://127.0.0.1:8000/

djangoblog's People

Contributors

dependabot[bot] avatar kersarh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.