To pass a large text parameter through a URL in Django, you can encode the text using base64 and then include it in the URL. Here is an example:

  1. Encode the text using base64:
import base64

big_text = 'This is a very long text that needs to be passed through the URL.'
encoded_text = base64.b64encode(big_text.encode()).decode()
  1. Include the encoded text in the URL:
from django.urls import reverse
from django.shortcuts import redirect

url = reverse('my_view') + f'?big_text={encoded_text}'
return redirect(url)
  1. Decode the text in your view:
import base64

def my_view(request):
    encoded_text = request.GET.get('big_text')
    decoded_text = base64.b64decode(encoded_text).decode()
    # Use the decoded_text in your view logic
    ...
Passing Large Text Parameters in Django URLs using Base64 Encoding

原文地址: https://www.cveoy.top/t/topic/mDgj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录