Skip to content

Commit

Permalink
Django-Gym-Website
Browse files Browse the repository at this point in the history
Django
  • Loading branch information
Rovshan Mammadli committed May 21, 2022
1 parent 30b25a5 commit 6af527a
Show file tree
Hide file tree
Showing 173 changed files with 7,016 additions and 0 deletions.
Empty file.
10 changes: 10 additions & 0 deletions gym_project/gym_con/blogs/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin
from .models import Blog

# Register your models here.
@admin.register(Blog)
class BlogAdmin(admin.ModelAdmin):
list_display = ('title','avaiable')
list_filter = ('avaiable',)
search_fields = ('title','subtitle')

6 changes: 6 additions & 0 deletions gym_project/gym_con/blogs/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BlogsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'blogs'
26 changes: 26 additions & 0 deletions gym_project/gym_con/blogs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.0.4 on 2022-05-16 19:56

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Blog',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, unique=True)),
('subtitle', models.CharField(max_length=200, unique=True)),
('content', models.TextField()),
('image', models.ImageField(default='blogs/default_blog_image.jpg', upload_to='blogs/%Y/%m/%d')),
('date', models.DateTimeField(auto_now=True)),
('avaiable', models.BooleanField(default=True)),
],
),
]
18 changes: 18 additions & 0 deletions gym_project/gym_con/blogs/migrations/0002_alter_blog_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-17 12:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='blog',
name='image',
field=models.ImageField(default='media/default_blog_image.jpg', upload_to='blogs/%Y/%m/%d'),
),
]
18 changes: 18 additions & 0 deletions gym_project/gym_con/blogs/migrations/0003_alter_blog_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-17 12:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0002_alter_blog_image'),
]

operations = [
migrations.AlterField(
model_name='blog',
name='image',
field=models.ImageField(default='blogs/default_blog_image.jpg', upload_to='blogs/%Y/%m/%d/'),
),
]
18 changes: 18 additions & 0 deletions gym_project/gym_con/blogs/migrations/0004_alter_blog_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-17 12:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0003_alter_blog_image'),
]

operations = [
migrations.AlterField(
model_name='blog',
name='image',
field=models.ImageField(default='media/default_blog_image.jpg', upload_to='blogs/%Y/%m/%d/'),
),
]
18 changes: 18 additions & 0 deletions gym_project/gym_con/blogs/migrations/0005_alter_blog_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-17 12:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blogs', '0004_alter_blog_image'),
]

operations = [
migrations.AlterField(
model_name='blog',
name='image',
field=models.ImageField(default='blogs/default_blog_image.jpg', upload_to='blogs/%Y/%m/%d/'),
),
]
17 changes: 17 additions & 0 deletions gym_project/gym_con/blogs/migrations/0006_alter_blog_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.4 on 2022-05-17 16:47

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blogs', '0005_alter_blog_image'),
]

operations = [
migrations.AlterModelOptions(
name='blog',
options={'ordering': ['-date']},
),
]
19 changes: 19 additions & 0 deletions gym_project/gym_con/blogs/migrations/0007_alter_blog_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.0.4 on 2022-05-20 22:43

import ckeditor.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blogs', '0006_alter_blog_options'),
]

operations = [
migrations.AlterField(
model_name='blog',
name='content',
field=ckeditor.fields.RichTextField(),
),
]
Empty file.
21 changes: 21 additions & 0 deletions gym_project/gym_con/blogs/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from datetime import date
from email.policy import default
from unicodedata import name
from django.db import models
from ckeditor.fields import RichTextField


class Blog(models.Model):
title = models.CharField(max_length=200, unique=True )
subtitle = models.CharField(max_length=200, unique=True )
content = RichTextField()
image = models.ImageField(upload_to="blogs/%Y/%m/%d/", default="blogs/default_blog_image.jpg")
date = models.DateTimeField(auto_now=True)
avaiable = models.BooleanField(default=True)

class Meta:
ordering = ['-date']


def __str__(self):
return self.title
3 changes: 3 additions & 0 deletions gym_project/gym_con/blogs/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions gym_project/gym_con/blogs/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

from django.urls import path
from . views import BlogPageView,BlogDetailView

urlpatterns = [
path('', BlogPageView.as_view(), name='blogs'),
path('blog/<int:pk>', BlogDetailView.as_view(), name='blog'),

]
18 changes: 18 additions & 0 deletions gym_project/gym_con/blogs/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from django.shortcuts import render
from django.views.generic import ListView,DetailView
from django.core.paginator import Paginator
from . models import Blog



class BlogPageView(ListView):
model = Blog
template_name = 'blogs.html'
paginate_by = 3

class BlogDetailView(DetailView):
model = Blog
template_name = 'blogpage.html'


Empty file.
16 changes: 16 additions & 0 deletions gym_project/gym_con/gym/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for gym project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gym.settings')

application = get_asgi_application()
133 changes: 133 additions & 0 deletions gym_project/gym_con/gym/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
"""
Django settings for gym project.
Generated by 'django-admin startproject' using Django 4.0.4.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-k7&h=ylcdauoe8cu=-xr9u7b7mo#a)furqs#9xkj0i9w-mw4ug'

# 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',
'pages.apps.PagesConfig',
'blogs.apps.BlogsConfig',
'trainers.apps.TrainersConfig',
'ckeditor',
]

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 = 'gym.urls'

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',
],
},
},
]

WSGI_APPLICATION = 'gym.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = 'static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
29 changes: 29 additions & 0 deletions gym_project/gym_con/gym/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""gym URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.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,include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('pages.urls')),
path('blogs/', include('blogs.urls')),
path('trainers/', include('trainers.urls')),

] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Loading

0 comments on commit 6af527a

Please sign in to comment.