Skip to content

Chapter 10 - #35

Open
sabderemane wants to merge 2 commits into
PacktPublishing:mainfrom
sabderemane:chapter10
Open

sabderemane wants to merge 2 commits into
PacktPublishing:mainfrom
sabderemane:chapter10

Conversation

@sabderemane

Copy link
Copy Markdown
Collaborator
  • Update to Django 6
  • addition. of HTMX with template partials

@sabderemane sabderemane self-assigned this Jul 29, 2026
valid_to = models.DateTimeField()
discount = models.IntegerField(
validators=[MinValueValidator(0), MaxValueValidator(100)],
help_text='Percentage vaule (0 to 100)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
help_text='Percentage vaule (0 to 100)',
help_text='Percentage value (0 to 100)',

order = Order.objects.get(id=session.client_reference_id)
except Order.DoesNotExist:
return HttpResponse(status=404)
# mark order as paid

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stripe works on an "at-least-once" delivery so this could run multiple times (docs)

Fix: Add if order.paid: return HttpResponse(status=200) before processing.

del self.cart[product_id]
self.save()

def clear(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing, but the coupon isn't cleared from the session so it's unlimited use?

tmp_key, 0, -1, desc=True
)[:max_results]
# remove the temporary key
r.delete(tmp_key)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not a concern at this scale, but with concurrency of a proper application, multiple requests at the same time with the same products would generate the same key.

Append uuid.uuid4().hex to make the key unique per request.

@marksweb

marksweb commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I've also an issue caused by weasyprint it seems;

OSError: cannot load library 'libgobject-2.0-0': dlopen(libgobject-2.0-0, 0x0002): tried: 'libgobject-2.0-0' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgobject-2.0-0' (no such file), '/usr/lib/libgobject-2.0-0' (no such file, not in dyld cache), 'libgobject-2.0-0' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libgobject-2.0-0' 

I'm not sure if we can flag somewhere the need for system setup to allow this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants