SHARE
TWEET

Untitled

a guest Oct 21st, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from business.models._business import Business, BusinessImage
  2.  
  3. def correct_descriptions():
  4.     s = 'امکانات هتل: \n\nامکانات اتاق: \n'  # should be replaced string
  5.     print(Business.objects.filter(_description__contains=s).count())
  6.  
  7.     for b in Business.objects.filter(_description__contains=s):
  8.         replace_s = 'امکانات هتل: {}\n\nامکانات اتاق: {}\n'.format(
  9.             '\n'.join(b.extra_data.get('eghamat_hotel_badges', [])),
  10.             '\n'.join(b.extra_data.get('eghamat_room_badges', []))
  11.         )
  12.         b._description = b.description.replace(s, replace_s)
  13.         b.save()
  14.         print(b.description)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top