New Django Developer

93 views
Skip to first unread message

Vinod Raygonda

unread,
Feb 1, 2023, 10:03:40 AM2/1/23
to Django users
Hi All, I am recently complete Django course with small projects
can any one help me to find real world projects to master Django,
i have basic knowledge about UI technologies.

Israel Akinoso

unread,
Feb 3, 2023, 6:58:21 AM2/3/23
to Django users
Can we collaborate on one together?
It'll boost us both :)

adeyinka newton

unread,
Feb 3, 2023, 10:27:33 AM2/3/23
to django...@googlegroups.com

You can change the upload path of Django Froala Editor to Cloudinary by using Cloudinary's upload API. Here is an example of how to do this:

Sign up for a Cloudinary account and get your cloud name, API key, and API secret.

Install the Cloudinary Python library:

settings.py:
===========
pip install cloudinary

Add the following settings in your Django settings file:


import os
import cloudinary
import cloudinary.uploader

CLOUDINARY_CLOUD_NAME = "your_cloud_name"
CLOUDINARY_API_KEY = "your_api_key"
CLOUDINARY_API_SECRET = "your_api_secret"

cloudinary.config(
  cloud_name = CLOUDINARY_CLOUD_NAME,
  api_key = CLOUDINARY_API_KEY,
  api_secret = CLOUDINARY_API_SECRET
)



In your Froala Editor view,
use the Cloudinary library to upload the image and return the URL to Froala Editor.
Here is an example view:


from django.http import JsonResponse
import cloudinary
import cloudinary.uploader

def froala_upload(request):
    if request.method == 'POST' and request.FILES.get('file'):
        try:
            response = cloudinary.uploader.upload(request.FILES['file'])
            return JsonResponse({
                'link': response['secure_url']
            })
        except Exception as e:
            return JsonResponse({
                'error': str(e)
            })
    return JsonResponse({
        'error': 'Invalid request'
    })



5.

Add the URL for the Froala upload view in your URL configuration:


from django.urls import path
from .views import froala_upload

urlpatterns = [
    path('froala_upload/', froala_upload, name='froala_upload'),
]



6.
In the Froala Editor options, set the imageUploadURL to the URL of your upload view.
 Here is an example:


$('#froala-editor').froalaEditor({
  imageUploadURL: '/froala_upload/'
});

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e674df39-8626-4403-b294-95ce4f843d57n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages