FormView get success url according to current language

PHOTO EMBED

Fri Oct 22 2021 00:15:38 GMT+0000 (UTC)

Saved by @adk000 #django #internationalization #localization #formview #forms #genericviews

// views.py
class SomeFormView(FormView):

    def get_success_url(self):
        if 'ka' in self.request.get_full_path():
            success_url = '/ka/message-sent/'
        elif 'en' in self.request.get_full_path():
            success_url = '/en/message-sent/'
        else:
            success_url = '/message-sent/'
        return success_url

// template.html
<form action="{% url 'app_name:message-sent' %}">
  	{% csrf_token %}
	{{ form }}  
</form>
content_copyCOPY

Tried it with get_language, couldn't make it work.