Blog / Software Development

How to reset the primary key sequence in PostgreSQL with Django

March 19, 2019

I was working on some fairly big features involving new Django models for one of our apps and when I pushed to our staging environment, I got this error during deployment at the database migration step:

duplicate key value violates unique constraint "auth_permission_pkey" DETAIL: Key (id)=(55) already exists

It looks like new records were getting added to the auth_permission table. I was puzzled as I didn't make any changes related to the Django auth app. …

Django 2.1 SameSite cookie issue with Safari 12

February 16, 2019

We just ran into this issue two days ago as we've recently upgraded the Django version for one of our Shopify apps to version 2.1.

We had a user tried to use the app and he kept getting redirected to the login page during the OAuth flow. He then tried it on Chrome and it worked fine so we narrowed down the issue to his web browser, which was Safari, specifically version 12 of Safari …

How to check if your Python app supports TLS 1.2

June 3, 2018

As you may have already heard, the Payment Card Industry (PCI) will be requiring everyone to use at least TLS 1.1 (1.2 is recommended) to meet their data security standard starting on June 30, 2018. Other services, such as PyPI, will be requiring only TLS 1.2 connections on the same date as well.

You need to make sure that the version of Python you're using and related packages support TLS 1.2 or a bunch …

How to delete all queues in RabbitMQ

January 21, 2018

I recently had to do this for one of my older Django projects that uses Celery as I made the mistake of using the broker as the result backend.

Using "amqp" as the result backend is not recommended in production as this will create a queue for each task. I noticed I was getting a warning for the file descriptors in the RabbitMQ web management dashboard.

From the web management (available by installing the management …

How to use proxies with an HTTP session using the Python requests package

December 26, 2017

I was working on a client project yesterday where I needed to use a proxy to make HTTP requests with the Python requests package.

In my use case, I needed to create a session and I wanted to just specify the proxy settings in one place and use that for all requests made through that session. I didn't see how to do this in the documentation so I thought I'd share my solution here.

Here's …