├── .gitattributes ├── LICENSE ├── README.md ├── db.sqlite3 ├── imageuploader ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-39.pyc │ ├── settings.cpython-39.pyc │ ├── urls.cpython-39.pyc │ └── wsgi.cpython-39.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py ├── media └── myimage │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 7.jpg │ └── 8.jpg └── myapp ├── __init__.py ├── __pycache__ ├── __init__.cpython-39.pyc ├── admin.cpython-39.pyc ├── forms.cpython-39.pyc ├── models.cpython-39.pyc └── views.cpython-39.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations ├── 0001_initial.py ├── __init__.py └── __pycache__ │ ├── 0001_initial.cpython-39.pyc │ └── __init__.cpython-39.pyc ├── models.py ├── templates └── myapp │ └── home.html ├── tests.py └── views.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Geeky Shows 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Django Image Uploader Website by Geeky Shows 2 | Watch Video Tutorial:- https://youtu.be/5TwCVOyYR4U 3 | 4 | Note - All images used in this project is licensed with Free for Commercial Use and No attribution Required. We have downloaded these iamges from pixabay. 5 | 6 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/db.sqlite3 -------------------------------------------------------------------------------- /imageuploader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/imageuploader/__init__.py -------------------------------------------------------------------------------- /imageuploader/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/imageuploader/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /imageuploader/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/imageuploader/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /imageuploader/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/imageuploader/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /imageuploader/__pycache__/wsgi.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/imageuploader/__pycache__/wsgi.cpython-39.pyc -------------------------------------------------------------------------------- /imageuploader/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for imageuploader 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.1/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', 'imageuploader.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /imageuploader/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for imageuploader project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.1.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.1/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'c(5@38zqb2kqad47011(x28l49tiwa2*&(&m&!m72o*o#26-lu' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 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 | 'myapp', 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 = 'imageuploader.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 = 'imageuploader.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': BASE_DIR / 'db.sqlite3', 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/3.1/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.1/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.1/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | MEDIA_URL = '/media/' 123 | MEDIA_ROOT = BASE_DIR / 'media' -------------------------------------------------------------------------------- /imageuploader/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path 3 | from django.conf import settings 4 | from django.conf.urls.static import static 5 | from myapp import views 6 | urlpatterns = [ 7 | path('admin/', admin.site.urls), 8 | path('', views.home) 9 | ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 10 | 11 | # print(static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)) 12 | -------------------------------------------------------------------------------- /imageuploader/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for imageuploader project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'imageuploader.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 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 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'imageuploader.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /media/myimage/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/1.jpg -------------------------------------------------------------------------------- /media/myimage/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/2.jpg -------------------------------------------------------------------------------- /media/myimage/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/3.jpg -------------------------------------------------------------------------------- /media/myimage/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/4.jpg -------------------------------------------------------------------------------- /media/myimage/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/5.jpg -------------------------------------------------------------------------------- /media/myimage/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/7.jpg -------------------------------------------------------------------------------- /media/myimage/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/media/myimage/8.jpg -------------------------------------------------------------------------------- /myapp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__init__.py -------------------------------------------------------------------------------- /myapp/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/forms.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__pycache__/forms.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Image 3 | # Register your models here. 4 | 5 | @admin.register(Image) 6 | class ImageAdmin(admin.ModelAdmin): 7 | list_display = ['id', 'photo', 'date'] 8 | -------------------------------------------------------------------------------- /myapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MyappConfig(AppConfig): 5 | name = 'myapp' 6 | -------------------------------------------------------------------------------- /myapp/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from .models import Image 3 | 4 | class ImageForm(forms.ModelForm): 5 | class Meta: 6 | model = Image 7 | fields = '__all__' 8 | labels = {'photo':''} -------------------------------------------------------------------------------- /myapp/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.2 on 2020-11-06 15:55 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Image', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('photo', models.ImageField(upload_to='myimage')), 19 | ('date', models.DateTimeField(auto_now_add=True)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /myapp/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/migrations/__init__.py -------------------------------------------------------------------------------- /myapp/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekyshow1/imageuploader/2ac750f21d08449b89ec7733b5cd9eed3a378e4c/myapp/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /myapp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Image(models.Model): 5 | photo = models.ImageField(upload_to="myimage") 6 | date = models.DateTimeField(auto_now_add=True) -------------------------------------------------------------------------------- /myapp/templates/myapp/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Image Uploader 12 | 13 | 14 |
15 |
16 |

Upload Image

17 |
18 | {% csrf_token %} 19 | {{form}} 20 | 21 |
22 |
23 |
24 | {% for x in img %} 25 |
26 |
27 | 28 | 31 |
32 |
33 | {% endfor %} 34 |
35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /myapp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /myapp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from .forms import ImageForm 3 | from .models import Image 4 | # Create your views here. 5 | 6 | def home(request): 7 | if request.method == "POST": 8 | form = ImageForm(request.POST, request.FILES) 9 | if form.is_valid(): 10 | form.save() 11 | form = ImageForm() 12 | img = Image.objects.all() 13 | return render(request, 'myapp/home.html', {'img':img, 'form':form}) --------------------------------------------------------------------------------