<form class="haha" id="foo1"> <!-- добавлен id формы -->
<input type="email" id="mail" name="user_email" />
</form>
<input type="text" id="name" name="user_name" form="foo1" /> <!-- внимание на атрибут form -->
class BookDeleteView(View):
def post(self, request, pk, *args, **kwargs):
data = dict()
book = Book.objects.get(pk=pk)
book.delete()
data['form_is_valid'] = True
context = {
'books': Book.objects.all()
}
data['html_books'] = render_to_string(
'books.html',
context
)
return JsonResponse(data)
def get(self, request, pk, *args, **kwargs):
data = dict()
book = Book.objects.get(pk=pk)
context = {
'book': book
}
data['html_book_delete_form'] = render_to_string(
'delete_book.html',
context,
request=request,
)
return JsonResponse(data)
import re
str1="""<тег>1</тег><тег>2</тег><тег>3</тег>"""
for res in re.findall(r'<тег>(.*?)<\/тег>', str1):
print(res)
>>> sunofdog = "{'d': '19', 'mon': '09', 'month': 'Сентябрь', 'address': 'Г. Кемерово ул. Ноградская д. 16, кв. 1'}"
>>> a = json.loads(sunofdog.replace("'",'"'))
>>> type(a)
"<class 'dict'>"
>>> b = eval(sunofdog)
>>> type(b)
"<class 'dict'>"
>>> a
{'d': '19', 'mon': '09', 'month': 'Сентябрь', 'address': 'Г. Кемерово ул. Ноградская д. 16, кв. 1'}
>>> a == b
True
>>>
>>> import ast
>>> c = ast.literal_eval(sunofdog)
>>> a == c
True
>>>