Recently I wanted to add a UUID field to an existing model called Institution, this model represents the Institutions that support the Open Library Humanities and the UUID field would represent a referral code. I added the following line to and ran makemigrations.

referral_code = models.UUIDField(default=uuid.uuid4)

Unfortunately, this works…

Allowing people to upload files to your server can be fraught with peril, we don’t want people to upload malicious files or binaries. In some cases we want to limit uploads to very specific file types, PDF or DOCX for example.

Python has a mimetype package that can be used…

Janeway (an open source publishing platform written in Python and using the Django framework) uses an event system that allows apps and plugins to register to be called when an event is fired. An example of this would be when a new submission is made.


This event is called…

Monkey-patching software is generally frowned upon, but there is a time and a place for everything, even monkey-patching.

Take Janeway for example, we were working nicely until we had a feature request from a developer who was thinking about using it: Could we handle multi-tenant journals without using multiple domains…

What does this mean!? Well, lets make an example.

class Company(models.Model):
name = models.CharField(max_length=100)
logo = models.ForeignKey(File, null=True, blank=True)
class File(models.Model):
filename = models.CharField(max_length=100)
mime = models.CharField(max_length=100)

Say we have an Company object and a File object. The file object is set to be the logo.

company = models.Company.objects.create(name='A Company')
file = models.File.objects.create(filename='file.jpg', mime='jpeg')
company.logo = file

If we then delete the file


Then we will actually also delete the company object because by default django will, on delete, cascade. So, we have to set the on_delete attribute to avoid this.

class Company(models.Model)
name = models.CharField(max_length=100)
logo = models.ForeignKey(File, null=True, blank=True, on_delete=models.SET_NULL)

If the File object is deleted nowm the logo will be set to NULL rather than deleting the object.

I’m currently converting chunks of code that make data changes on GET requests to use POST within the Django environment and thought it might be useful to document how I did it here.

Here is a snippet of code using a GET request to change data using a query string…

On the 12th of October I will be moving on from my post as Technical Architect at Ubiquity Press. I’ve had a great time working on cutting edge publishing technology and working alongside the teams at UP and our partner presses to provide a great experience

During my tenure with…

Andy Byers

Pub Tech developer for Birkbeck CTP

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store