diff options
Diffstat (limited to 'app/utils')
-rw-r--r-- | app/utils/util.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/utils/util.py b/app/utils/util.py index 93ae5b1..dc04b0b 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -53,9 +53,11 @@ def extract_main_image(markdown): def parse_products(s): soup = BeautifulSoup(s.group(), "lxml") for div in soup.find_all('div'): - p = apps.get_model('products', 'Product').objects.get(pk=int(div['id'].split("product-")[1])) - print(p.get_full_name()) - return render_to_string("products/snippet.html", {'object': p}) + try: + p = apps.get_model('products', 'Product').objects.get(pk=int(div['id'].split("product-")[1])) + return render_to_string("products/snippet.html", {'object': p}) + except KeyError: + return str(s) def parse_image(s): @@ -67,7 +69,7 @@ def parse_image(s): replacer = "[[base_url]]" if replacer in str(img): s = str(img).replace('[[base_url]]', settings.IMAGES_URL) - print(s) + #print(s) return s else: try: |