To pass a big 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
    ...
django pass bigtext param through url

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

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