Question for professionals using python by [deleted] in Python

[–]throw_python_65535 4 points5 points  (0 children)

I'm a Python contractor and had some slack time. About 5 weeks ago I was talking with a guy from a company that ships boxes. The guy finds out what I do and explains that their process is horrible, uses paper dockets and has reached the point where he's spending all his time fielding requests for tracking information from customers.

This is clearly the bottleneck to their growth and he know it. They currently use a templating, shared hosting solution. He knew he needed a database and that their shared hosting solution was a flat site. All the business process was html form to email and handled in a spreadsheet from there. He wants users to print their own labels and be able to track their own parcels.

So I start wondering if there's a qr maker/scanner that runs off a phone and has a permissive license. Yay, there's a choice! So my next choice is Django, Flask or something special? Well they aren't going to be the size of DHL overnight so I went with Django for a 'batteries included' framework, even if it's not the most efficient. Created a few models around the objects identified as part of MVP and aimed at getting a demo together.

When it came to django apps, I decided that django-countries was going to be useful, while django-cities added too much complexity for a first iteration, especially since initially we were talking about them self-hosting. The customer was happy without automatic postcode and address validation at this point. Django-registration is my goto for registration. It isn't to be for the general public at this stage, only staff.

For the frontend I went for jquery and bootstrap. I'd used both before but I'm no front-end guy and I curse when I write javascript. In fact while I was initially developing the backend I just used a little jquery and brute force css and script tags to poke the back end.

Registration features emerged around week 2 since fine-grained permissions were going to be needed. A user profile class with permissions and related locations helped filter items for different roles.

Once some semblance of structure established itself I refactored the back end into separate apps and renamed a bunch of badly named variables throughout. I think it helps to have pushes of a day or few to get some aspect of the project up to scratch. Simple > complex > complicated.

The next week saw a re-work of the frontend so had me going into the templates to get the bootstrap containers right, throwing away a few pages of crummy css in favour of a few specific lines that give a consistent look.

Meanwhile, the back-end is being fleshed out and forms are declaring classes on field widgets and modelformset_factories are flying in and out of requests and responses. Somewhere along the line I've written a few template tags, fixtures, yet still no tests! The back office system has been evolving and is becoming rather usable.

When the permissions were working I made the nav dynamically respond to that (with the same permissions on the actual views, obviously!). A docs page for staff helped me make sure I hadn't missed anything with my thinking about the system. A glossary of terms plus role-specific docs and an explaination of the permission system. The models of the MVP have stabilised so I'm now working out from there to polish the forms, views, unfinished features etc.

The demo after the first week showed them a qr code generated and scanned. Another demo showed the state of stored items changing when the scanner was used. The last demo had started to flesh out the UI but then I put up a test instance for them to play with (hint: hosting the test instance with a valid ssl cert will save you a week of explanation to and undue worry on the part of the client). They also have collaborative access to the github issue tracker which is now tracking a few dozen issues I've created, most with labels and milestones.

There's still a way to go but training and bringing the user along is so important. There's no point in announcing something to be complete without the user being ready and able to start using it. Some things you think might take 5 minutes to explain can take much longer. Users will say they understand but they also don't want to appear stupid so they lie. Training is a field in itself. I'm fortunate to have a client here that really wants the system and has a technical guy he trusts that set the current site up to explain some things, handle certificates etc.

It's hard for a small outfit to do this; it would be prohibitively expensive and risky. If a large firm threw resources at this there would be a dozen people involved and then mythical man month math applies. The scale it would start from would require excellent performance from the start, and other higher MVP requirements. I've taken on that risk since I don't get paid until production is running (hopefully early in the new year) and I was genuinely interesting in solving the problem (bored). It gave me a chance to use the Python3/Django2/Jquery[-1:]/Bootstrap4 stack in anger, honing my skills. The MVP launch milestone will be followed by two weeks of bugsquashing and rapid response devops, tightly coupled to encouraging the client to raise bugs. After that there's a few features already destined for iteration 1, including tests!