Skip to content

Commit 0b310ee

Browse files
committed
''
0 parents  commit 0b310ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+487
-0
lines changed

db.sqlite3

136 KB
Binary file not shown.

first/__init__.py

Whitespace-only changes.
124 Bytes
Binary file not shown.
235 Bytes
Binary file not shown.
822 Bytes
Binary file not shown.

first/__pycache__/urls.cpython-38.pyc

282 Bytes
Binary file not shown.
429 Bytes
Binary file not shown.

first/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django.contrib import admin
2+
from .models import Card
3+
# Register your models here.
4+
admin.site.register(Card)

first/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class FirstConfig(AppConfig):
5+
name = 'first'

first/migrations/0001_initial.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.0.6 on 2020-05-17 22:52
2+
3+
from django.db import migrations, models
4+
5+
# the model gets migrated (created) in the database which its db.sqlite3 in the main folder
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Cards',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('image', models.ImageField(height_field='image_height', max_length=200, upload_to='', width_field='image_width')),
19+
('qoute', models.CharField(max_length=200)),
20+
('date', models.DateTimeField(auto_now_add=True)),
21+
],
22+
),
23+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 3.0.6 on 2020-05-18 15:09
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('first', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Card',
15+
fields=[
16+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('image', models.ImageField(max_length=200, upload_to='')),
18+
('qoute', models.CharField(max_length=200)),
19+
('date', models.DateTimeField(auto_now_add=True)),
20+
],
21+
),
22+
migrations.DeleteModel(
23+
name='Cards',
24+
),
25+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.0.6 on 2020-05-18 21:17
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('first', '0002_auto_20200518_1909'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='card',
15+
name='qoute',
16+
field=models.TextField(max_length=200),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.0.6 on 2020-05-22 03:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('first', '0003_auto_20200519_0117'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='card',
15+
name='qoute',
16+
field=models.CharField(max_length=50),
17+
),
18+
]

first/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

first/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from django.db import models
2+
from django.db.models.signals import post_delete
3+
from django.dispatch import receiver
4+
5+
# Create your models here.
6+
7+
8+
class Card(models.Model): #creating model and the fields needed
9+
image = models.ImageField(max_length = 200)
10+
qoute = models.CharField(max_length = 50)
11+
date = models.DateTimeField(auto_now_add= True)
12+
13+
14+
#to delete image from media file when you delete object from admin.
15+
@receiver(post_delete, sender=Card)
16+
def photo_post_delete_handler(sender, **kwargs):
17+
photo = kwargs['instance']
18+
storage, path = photo.image.storage, photo.image.path
19+
storage.delete(path)

first/templates/base.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{% load static%}
2+
<!DOCTYPE html>
3+
<html lang="en" dir="ltr">
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
8+
<link rel="stylesheet" href="{% static 'main.css' %}">
9+
<title>My blog</title>
10+
</head>
11+
<body>
12+
13+
<nav class="navbar sticky-top navbar-expand-lg navbar-light mb-3" id = "nav">
14+
<a class="navbar-brand" href="#">Blog</a>
15+
<!-- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
16+
<span class="navbar-toggler-icon"></span>
17+
</button>
18+
19+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
20+
<ul class="navbar-nav mr-auto">
21+
<li class="nav-item active">
22+
<a class="nav-link" href="#">photos<span class="sr-only">(current)</span></a>
23+
</li>
24+
<li class="nav-item">
25+
<a class="nav-link" href="#">videos</a>
26+
</li>
27+
28+
</ul>
29+
</div> -->
30+
</nav>
31+
32+
<div class="container-fluid">
33+
<div class = "card-columns">
34+
{% for i in card %}
35+
<div class="card p-3" style="width: 18rem;" id = 'card'>
36+
<img src="{{i.image.url}}" class="card-img-top img-fluid" alt="Card image cap">
37+
<div class="card-body">
38+
<p class="card-text">{{i.qoute}}</p>
39+
</div>
40+
</div>
41+
{% endfor %}
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
59+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
60+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
61+
</body>
62+
</html>

first/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

first/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
from django.contrib import admin
3+
from django.urls import path
4+
from . import views
5+
6+
urlpatterns = [
7+
path('', views.index),
8+
]

first/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from django.shortcuts import render
2+
from django.http import HttpResponse
3+
from .models import Card
4+
# Create your views here.
5+
6+
7+
8+
def index(request):
9+
card = Card.objects.all()
10+
return render(request,"base.html" , {'card':card})

manage.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myblog.settings')
9+
try:
10+
from django.core.management import execute_from_command_line
11+
except ImportError as exc:
12+
raise ImportError(
13+
"Couldn't import Django. Are you sure it's installed and "
14+
"available on your PYTHONPATH environment variable? Did you "
15+
"forget to activate a virtual environment?"
16+
) from exc
17+
execute_from_command_line(sys.argv)
18+
19+
20+
if __name__ == '__main__':
21+
main()
1.87 MB
Loading
2.27 MB
Loading

media/IMG_3525.JPG

433 KB
Loading

media/IMG_4116.JPG

2.51 MB
Loading

media/IMG_4607.JPG

2.36 MB
Loading

media/IMG_4673.JPG

1.57 MB
Loading

media/IMG_4797.JPG

494 KB
Loading

myblog/__init__.py

Whitespace-only changes.
125 Bytes
Binary file not shown.
2.34 KB
Binary file not shown.
1.09 KB
Binary file not shown.
525 Bytes
Binary file not shown.

myblog/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for myblog project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myblog.settings')
15+
16+
application = get_asgi_application()

myblog/settings.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""
2+
Django settings for myblog project.
3+
4+
Generated by 'django-admin startproject' using Django 3.0.6.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.0/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = '8b6l&l7!s*+s#pyj&-+9e8b%)qe#nc5c#r2=skc!*hc$k$@@^&'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = ['192.168.0.104','127.0.0.1']
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'first',
41+
]
42+
43+
MIDDLEWARE = [
44+
'django.middleware.security.SecurityMiddleware',
45+
'django.contrib.sessions.middleware.SessionMiddleware',
46+
'django.middleware.common.CommonMiddleware',
47+
'django.middleware.csrf.CsrfViewMiddleware',
48+
'django.contrib.auth.middleware.AuthenticationMiddleware',
49+
'django.contrib.messages.middleware.MessageMiddleware',
50+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
51+
]
52+
53+
ROOT_URLCONF = 'myblog.urls'
54+
55+
TEMPLATES = [
56+
{
57+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
58+
'DIRS': [],
59+
'APP_DIRS': True,
60+
'OPTIONS': {
61+
'context_processors': [
62+
'django.template.context_processors.debug',
63+
'django.template.context_processors.request',
64+
'django.contrib.auth.context_processors.auth',
65+
'django.contrib.messages.context_processors.messages',
66+
],
67+
},
68+
},
69+
]
70+
71+
WSGI_APPLICATION = 'myblog.wsgi.application'
72+
73+
74+
# Database
75+
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
76+
77+
DATABASES = {
78+
'default': {
79+
'ENGINE': 'django.db.backends.sqlite3',
80+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
81+
}
82+
}
83+
84+
85+
# Password validation
86+
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
87+
88+
AUTH_PASSWORD_VALIDATORS = [
89+
{
90+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91+
},
92+
{
93+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94+
},
95+
{
96+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97+
},
98+
{
99+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100+
},
101+
]
102+
103+
104+
# Internationalization
105+
# https://docs.djangoproject.com/en/3.0/topics/i18n/
106+
107+
LANGUAGE_CODE = 'en-us'
108+
109+
TIME_ZONE = 'UTC'
110+
111+
USE_I18N = True
112+
113+
USE_L10N = True
114+
115+
USE_TZ = True
116+
117+
118+
# Static files (CSS, JavaScript, Images)
119+
# https://docs.djangoproject.com/en/3.0/howto/static-files/
120+
121+
STATIC_URL = '/static/'
122+
123+
STATICFILES_DIRS = (
124+
os.path.join(BASE_DIR, 'static/'),
125+
)
126+
127+
MEDIA_URL = '/media/'
128+
MEDIA_ROOT = 'media'

0 commit comments

Comments
 (0)