Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- def wrap(to_wrap, wrap_in):
- contents = to_wrap.replace_with(wrap_in)
- wrap_in.append(contents)
- for obj in Post.objects.all():
- soup = BeautifulSoup(obj.content, 'html.parser')
- for item in soup.children:
- if item.name is None:
- wrap(item, soup.new_tag("p"))
- obj.content = str(soup)
- obj.save()
Add Comment
Please, Sign In to add comment