from django.http import HttpResponse
def set_language(request):
language = request.GET.get('language', '')
print(language,111)
language = get_language()
print(language,222)
if language:
response = HttpResponse()
response['Content-Language'] = language
response['Content-Type'] = 'text/plain; charset=utf-8'
# Возможно, также стоит установить язык в куки для сохранения предпочтений пользователя
response.set_cookie('django_language', language)
return response
t_begin = forms.SplitDateTimeField(widget=widgets.AdminSplitDateTime())
t_end = forms.SplitDateTimeField(widget=widgets.AdminSplitDateTime())
from django.contrib.admin.widgets import AdminDateWidget, AdminTimeWidget, AdminSplitDateTime
class LabForm(forms.ModelForm):
class Meta:
model = Lab
fields = (
'name','description','t_begin','t_end','address',
)
labels = {
'name':'Название мероприятия',
'description':'Описание мероприятия',
't_begin':'Начало',
't_end':'Окончание',
'address':'Адрес',
}
widgets = {'t_begin': AdminSplitDateTime(),'t_end': AdminSplitDateTime(),}
<form method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit" />
</form>
form = LabForm(request.POST or None)
print(form)
if form.is_valid():