Communicate between Python Script and Django


For the past 2 days I have been trying to solve this problem. I will try to explain it as simply as possible.

My system has 2 parts:

  1. Python Script
  2. Django Dashboard Template.

The python script uses the adafruit circuitpython fingerprint library to communicate with a fingerprint sensor.

The main problem is that I need to be able to communicate between the two so that the various states of the fingerprint sensor can be communicated with the Django project.

The fingerprint data will be stored on the sensor itself, only returning the id of the matched print.

The functions in the fingerprint library go through many states, place finger, place finger again, error etc, and the Django app has to show a different message on screen each time a new state is encountered.

The fingerprint sensor will be used to sign in and login to the dashboard, so the dashboard also has to send messages to the python script about when to start enrolling fingerprints, or checking for fingerprint matches.

I am already using a database MySQL, but sending messages through the database will be impractical as I want live message transfer.

If anyone has a better solution, please feel free to share, but currently I have been unable to effective send and receive messages between the two parts.

This type of situation has been talked about a couple times previously here. One I found right off-hand is How to integrate GPIO input into django?

Briefly, I would do this using Channels. I’d have the stand-alone Python script post data to a Django Channels group. One (or more!) browsers can then join that group to receive the messages.

1 Like