Guest User

Untitled

a guest
Mar 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2.  
  3. def wrap(to_wrap, wrap_in):
  4. contents = to_wrap.replace_with(wrap_in)
  5. wrap_in.append(contents)
  6.  
  7. for obj in Post.objects.all():
  8. soup = BeautifulSoup(obj.content, 'html.parser')
  9. for item in soup.children:
  10. if item.name is None:
  11. wrap(item, soup.new_tag("p"))
  12.  
  13. obj.content = str(soup)
  14. obj.save()
Add Comment
Please, Sign In to add comment