IT FINALLY CLICKED, added logic behind uploads
This commit is contained in:
parent
b3195368ee
commit
348a0a09bc
Binary file not shown.
Binary file not shown.
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'home',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -15,7 +15,13 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from home.models import upload_video,upload_image
|
||||||
|
from home.views import upload_content, imageUpload, videoUpload
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('upload/',upload_content, name="upload"),
|
||||||
|
path('upload_video/',videoUpload,name='upload_video'),
|
||||||
|
path('upload_image/',imageUpload,name='upload_image'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
BIN
currencyproj/db.sqlite3
Normal file
BIN
currencyproj/db.sqlite3
Normal file
Binary file not shown.
@ -1,3 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from .models import upload_image, upload_video
|
||||||
|
|
||||||
# Register your models here.
|
admin.site.register(upload_image)
|
||||||
|
admin.site.register(upload_video)
|
||||||
|
22
currencyproj/home/migrations/0001_initial.py
Normal file
22
currencyproj/home/migrations/0001_initial.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-02-05 00:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='upload',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('image', models.FileField(upload_to='images/')),
|
||||||
|
('video', models.FileField(upload_to='videos/')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
30
currencyproj/home/migrations/0002_auto_20210205_0037.py
Normal file
30
currencyproj/home/migrations/0002_auto_20210205_0037.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-02-05 00:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('home', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='upload_image',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('image', models.FileField(upload_to='images/')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='upload_video',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('video', models.FileField(upload_to='videos/')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='upload',
|
||||||
|
),
|
||||||
|
]
|
@ -1,6 +1,8 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
class Ticker(models.Model):
|
class upload_image(models.Model):
|
||||||
f = open("../currency.txt","r")
|
# check for file extensions
|
||||||
a = f.readline()
|
image = models.FileField(upload_to="images/")
|
||||||
print(a)
|
|
||||||
|
class upload_video(models.Model):
|
||||||
|
video = models.FileField(upload_to="videos/")
|
||||||
|
20
currencyproj/home/templates/index.html
Normal file
20
currencyproj/home/templates/index.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form action="" method="POST">{% csrf_token %}
|
||||||
|
<label for="choice">What are we gonna upload today?</label>
|
||||||
|
<select name="choices" id="choices">
|
||||||
|
<option value="image">Picture</option>
|
||||||
|
<option value="video">Video</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="submit"> Submit </button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
currencyproj/home/templates/uploadImage.html
Normal file
10
currencyproj/home/templates/uploadImage.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>test 1</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
currencyproj/home/templates/uploadVideo.html
Normal file
10
currencyproj/home/templates/uploadVideo.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>test2</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>test2</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,3 +1,40 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
|
|
||||||
# Create your views here.
|
from .models import upload_video,upload_image
|
||||||
|
|
||||||
|
def imageUpload(request):
|
||||||
|
if request.method == "GET":
|
||||||
|
return render(request, "uploadImage.html")
|
||||||
|
elif request.method == "POST":
|
||||||
|
image = request.POST["image"]
|
||||||
|
# add the id of the user, after you add in users
|
||||||
|
return upload_image(image)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
def videoUpload(request):
|
||||||
|
if request.method == "GET":
|
||||||
|
return render(request, "uploadVideo.html")
|
||||||
|
elif request.method == "POST":
|
||||||
|
video = request.POST["video"]
|
||||||
|
# add the id of the user, after you add in users
|
||||||
|
return upload_video(video)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def upload_content(request):
|
||||||
|
if request.method == "GET":
|
||||||
|
return render(request, "index.html")
|
||||||
|
elif request.method == "POST":
|
||||||
|
choice = request.POST["choices"]
|
||||||
|
if choice == "image":
|
||||||
|
return redirect("/upload_image/")
|
||||||
|
elif choice == "video":
|
||||||
|
return redirect("/upload_video/")
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
# in conclusion - im genious, good job boyan lmao
|
||||||
|
BIN
currencyproj/images/Screenshot_at_2021-01-19_03-15-00.png
Normal file
BIN
currencyproj/images/Screenshot_at_2021-01-19_03-15-00.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
BIN
currencyproj/videos/Screenshot_at_2021-01-19_03-15-00.png
Normal file
BIN
currencyproj/videos/Screenshot_at_2021-01-19_03-15-00.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
Binary file not shown.
After Width: | Height: | Size: 240 KiB |
Reference in New Issue
Block a user