@login_required(login_url='/accounts/login/')
def create_profile(request):
    title = 'Moments: Create New Profile'
    form = NewProfileForm(request.POST, request.FILES)
    current_profile = Profile.objects.filter(user_name=request.user.username).first()
    if ((request.method == 'POST') and request.FILES['profile_photo']):
        if form.is_valid():
            new_profile_photo = request.FILES['profile_photo']
            new_bio = form.cleaned_data['bio']
            print(new_bio)
            username = request.user.username
            date_joined = request.user.date_joined
            new_profile = Profile(profile_photo=new_profile_photo, bio=new_bio, user_name=username, following=[], followers=[], joined=date_joined)
            new_profile.save()
            return redirect('Dashboard')
        else:
            form = NewProfileForm()
    return render(request, 'create_profile.html', {'title': title, 'form': form, 'profile': current_profile})
@login_required(login_url='/accounts/login/')
def create_profile(request):
    title = 'Moments: Create New Profile'
    form = NewProfileForm(request.POST, request.FILES)
    current_profile = Profile.objects.filter(user_name=request.user.username).first()
    if ((request.method == 'POST') and request.FILES['profile_photo']):
        if form.is_valid():
            new_profile_photo = request.FILES['profile_photo']
            new_bio = form.cleaned_data['bio']
            print(new_bio)
            username = request.user.username
            date_joined = request.user.date_joined
            new_profile = Profile(profile_photo=new_profile_photo, bio=new_bio, user_name=username, following=[], followers=[], joined=date_joined)
            new_profile.save()
            return redirect('Dashboard')
        else:
            form = NewProfileForm()
    return render(request, 'create_profile.html', {'title': title, 'form': form, 'profile': current_profile})