Django #1

Merged
confestim merged 14 commits from django into main 2021-02-09 00:09:09 +01:00
17 changed files with 147 additions and 7 deletions
Showing only changes of commit 348a0a09bc - Show all commits

View File

@ -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 = [

View File

@ -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

Binary file not shown.

View File

@ -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)

View 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/')),
],
),
]

View 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',
),
]

View File

@ -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/")

View 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>

View 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>

View 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>

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB