我试图让每个用户将多张图片上传到一篇博文.我一直试图找出最好的方法来做几天.这样做的最佳做法是什么?
根据我的阅读,我应该从博客文章模型中创建一个单独的图像模型并使用外键.是对的吗?然后是如何允许他们同时上传多张图片的问题.我是否正确地假设我应该使用像drop zone这样的东西?
有关存储照片的最佳做法的任何建议也是受欢迎的.我看过亚马逊s3和cloudinary.我想创建一些可扩展的东西.
任何帮助将非常感激!
我是django的新手,我目前正在尝试建立一个允许用户登录并查看其他用户个人资料的网站.到目前为止,我已设法让用户登录,但我无法弄清楚如何查看其他人的个人资料.
每个配置文件都使用用户名为其个人资料创建网址.目前,如果我以一个用户身份登录并将URL更改为另一个用户配置文件URL,则它仍会显示当前用户配置文件.我想要一些类似于pinterest的东西,任何人无论是否登录都可以查看人物档案.
任何帮助,将不胜感激!
视图
from django.http import HttpResponse
from django.shortcuts import render
from howdidu.forms import UserProfileForm
from howdidu.models import UserProfile
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User
def index(request):
context_dict = {'boldmessage': "I am bold font from the context"}
return render(request, 'howdidu/index.html', context_dict)
#user profile form
@login_required
def register_profile(request):
profile = UserProfile.objects.get(user=request.user)
if request.method == 'POST':
form = UserProfileForm(request.POST, request.FILES, instance=profile)
if form.is_valid():
form.save()
return index(request)
else:
print form.errors
else:
form = UserProfileForm()
return render(request, …Run Code Online (Sandbox Code Playgroud)