we did it bois, we enter in the user id for each one
This commit is contained in:
parent
322047b51b
commit
a62ccb389d
Binary file not shown.
BIN
website/home/__pycache__/admin.cpython-38.pyc
Normal file
BIN
website/home/__pycache__/admin.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/home/__pycache__/models.cpython-38.pyc
Normal file
BIN
website/home/__pycache__/models.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/home/__pycache__/views.cpython-38.pyc
Normal file
BIN
website/home/__pycache__/views.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/media/images/Firefox_wallpaper.png
Normal file
BIN
website/media/images/Firefox_wallpaper.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
BIN
website/media/images/Firefox_wallpaper_DWC6NUM.png
Normal file
BIN
website/media/images/Firefox_wallpaper_DWC6NUM.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
BIN
website/media/images/Firefox_wallpaper_K3hB2TP.png
Normal file
BIN
website/media/images/Firefox_wallpaper_K3hB2TP.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
BIN
website/media/images/Firefox_wallpaper_SdWEpTL.png
Normal file
BIN
website/media/images/Firefox_wallpaper_SdWEpTL.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
BIN
website/media/images/Screenshot_from_2020-03-06_10-58-51.png
Normal file
BIN
website/media/images/Screenshot_from_2020-03-06_10-58-51.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 772 KiB |
@ -4,7 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
{% if user.is_authenticated %}
|
||||
Hi {{ user.username }}!<br>
|
||||
Hi {{ user.username }} {{ user.id }}!<br>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
|
BIN
website/upload/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/admin.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/admin.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/forms.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/forms.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/models.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/models.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/validators.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/validators.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/upload/__pycache__/views.cpython-38.pyc
Normal file
BIN
website/upload/__pycache__/views.cpython-38.pyc
Normal file
Binary file not shown.
32
website/upload/migrations/0006_auto_20210218_0008.py
Normal file
32
website/upload/migrations/0006_auto_20210218_0008.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Generated by Django 3.1.6 on 2021-02-17 22:08
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import upload.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('upload', '0005_videos'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='image',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='image',
|
||||
name='image',
|
||||
field=models.ImageField(upload_to='images/', validators=[upload.validators.imageValidate]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='videos',
|
||||
name='video',
|
||||
field=models.FileField(upload_to='videos/', validators=[upload.validators.videoValidate]),
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
website/upload/migrations/__pycache__/0005_videos.cpython-38.pyc
Normal file
BIN
website/upload/migrations/__pycache__/0005_videos.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
website/upload/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
website/upload/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from .validators import videoValidate, imageValidate
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
# def user_directory._path(instance, filename):
|
||||
# print(request.user.id)
|
||||
@ -10,7 +11,8 @@ from .validators import videoValidate, imageValidate
|
||||
|
||||
class Image(models.Model):
|
||||
title = models.CharField(max_length=200)
|
||||
image = models.ImageField(upload_to=f"images/{upload_to}",validators=[imageValidate])
|
||||
image = models.ImageField(upload_to=f"images/",validators=[imageValidate])
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
@ -22,12 +22,15 @@ def uploadContent(request):
|
||||
|
||||
def imageUpload(request):
|
||||
"""Process images uploaded by users"""
|
||||
|
||||
print(request.user.id)
|
||||
if request.method == 'POST':
|
||||
form = ImageForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
# Get the current instance object to display in the template
|
||||
img_obj = form.instance
|
||||
img_obj.user = request.user
|
||||
form.save()
|
||||
return render(request, 'uploadImage.html', {'form': form, 'img_obj': img_obj})
|
||||
|
||||
else:
|
||||
@ -46,4 +49,3 @@ def videoUpload(request):
|
||||
else:
|
||||
form = VideoForm()
|
||||
return render(request, 'uploadVideo.html', {'form': form})
|
||||
|
||||
|
BIN
website/users/__pycache__/admin.cpython-38.pyc
Normal file
BIN
website/users/__pycache__/admin.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/users/__pycache__/models.cpython-38.pyc
Normal file
BIN
website/users/__pycache__/models.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/users/__pycache__/urls.cpython-38.pyc
Normal file
BIN
website/users/__pycache__/urls.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/users/__pycache__/views.cpython-38.pyc
Normal file
BIN
website/users/__pycache__/views.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/website/__pycache__/settings.cpython-37.pyc
Normal file
BIN
website/website/__pycache__/settings.cpython-37.pyc
Normal file
Binary file not shown.
BIN
website/website/__pycache__/settings.cpython-38.pyc
Normal file
BIN
website/website/__pycache__/settings.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/website/__pycache__/urls.cpython-38.pyc
Normal file
BIN
website/website/__pycache__/urls.cpython-38.pyc
Normal file
Binary file not shown.
BIN
website/website/__pycache__/wsgi.cpython-38.pyc
Normal file
BIN
website/website/__pycache__/wsgi.cpython-38.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user