Templates and Static Files in Puput

Templates and Static Files in Puput

One of the ways Puput really confuses me is its not adding a visible app into the project folder. Normally, when you run “django-admin manage.py startapp app_name_here”, you see a folder for your app appear. Not with Puput. I haven’t figured it out completely yet but I think the app is somehow integrated into the Puput package in the Python folder. Or, maybe the app isn’t really in the package folder, but it simply acts as the app itself and uses your database to generate the web site. I don’t know.

I need to override Puput’s templates and static files, and this Stack Overflow post shows that you can do that with the template files. But for the life of me I couldn’t use the same principle or find another way to override the static files. (UPDATE: figured it out, same principle does apply, I mistook PROJECT_DIR for BASE_DIR.)

It led me to another question though. What’s the difference between STATICFILES_DIR, STATIC_ROOT, and STATIC_URL? This post answers it in part. But I still can’t override the static files. I tried reverse-engineering the Puput package but I’m not good enough to figure it out yet.

Well. I guess I’ll edit the source static files directly for now. Not a good idea, I know. But I can’t just sit around stalled all the ruddy week.

Notes on Installing Puput on Wagtail on Django

Notes on Installing Puput on Wagtail on Django

This is a brief one, I hope.

I wanted to save time so I learnt Django. Then I wanted to save more time building a CMS and a blog so I learnt Wagtail. Then I wanted to save even more time so I learnt Puput. The problem was, as I went from Django to Wagtail to Puput, the documentation got thinner and thinner and thinner. And more and more and more abstract. Not ideal for beginners, at all.

Wagtail “Post date” Problem

I followed the Wagtail introductory tutorial strictly, but when I used “date = models.DateField(“Post date”)” like in the tutorial, I kept getting: “django.core.exceptions.ValidationError: [“‘Post date’ value has an invalid date format. It must be in YYYY-MM-DD format.”]”.

After googling for a full day, I got fed up and visited the Wagtail channel on IRC Freenode where someone said to run “manage.py migrate blog zero”, remove all files in the migrations folder except for __init__.py and then run makemigrations and migrate again to start from scratch. That meant all my test posts were gone but it fixed the problem.

Nobody knew exactly what went wrong. I suspect it’s because when we follow tutorials and test things out in different ways we might create conflicts in the database. I don’t know. Just guessing.

Puput Installation Problem

The bigger problem arrived when I tried to integrate Puput into my Wagtail project. The documentation does tell you how to do it, except that it throws up a few errors irresolvable by beginners. Since I didn’t have a full blown blog I had to integrate, I was comfortable dumping my test Wagtail blog entirely and building the Puput one from scratch.

The Puput setup documentation says you have to do different things depending on whether you’re installing Puput on top of Wagtail or on top of Django. I’ve found neither to work when strictly followed. Instead, what worked was when I followed the setup instructions for integrating Puput into a Django project minus the part where you add PUPUT_APPS into INSTALLED_APPS.

Once I left it out, I could migrate without error code 1 and other errors showing up. Then I could build the blog up from scratch.

Other Issues

I solved a handful of other problems by following the code. If the tutorial said to do something but it didn’t work, I would go into the Puput package, weasel out the module I’m supposed to be referencing, find the appropriate code in it, and try to understand what exactly it does. This was harder than I thought, since half of it didn’t make sense to me. The other half did though, thankfully.

Wagtail works slightly differently from Django, and Puput is almost entirely different structurally. They’re not difficult to understand. It just takes a lot of time, googling, and asking around, and thank goodness for IRC, amirite?

I thought using open source packages would save me time, and perhaps it will in the long run. I do really like Puput and Wagtail and Django. But it can be really hard on beginners, especially when some of us have to work to pay the rent and we’re stealing literally ten bare minutes off the end of the day to learn this stuff with bleary eyes and tired minds.

Clear documentation and tutorials are so important. I hope I get some free time and energy to write up clearer ones for Puput soon.

Projects so far

Projects so far

Documenting what I’ve built so far. I don’t have the $$ to host these yet, so, I’ll post pics for now.

The Nomurica Constant International Film Fest

I built this web app to counter the winner-takes-all effect in popular culture. American culture saturates every last bit of our environment, and I felt this buried great works from the rest of the world six feet under. So, I took the IMDB database, banned all films from America and most of the West, and let my algorithm randomly pick ten films from around the world, scrape YouTube for their trailers, and post them on a webpage.

I built this in Flask, and the code is shoddy because I made this before I learnt more about MVC. I know better now, and I’ll rebuild it in Django when I have the time. This experience also let me understand how much faster it is to use PostgreSQL over SQLite3.

I think, even considering its many faults right now, it looks like significantly effective proof-of-concept that it is more than possible to remedy the winner-takes-all effect, and consequently, cultural hegemony.

nomurica constant international film fest page 1


I built this app as an exercise in both language and code. Essentially, I constructed a way to randomly concatenate several lists of strings so that they always turn out grammatically correct. The background slowly segues from one colour to another, and the text also changes every so often.

It’s also built in Flask.


A social media site

I’ve also built, in Flask, a social media site where people log in and out and share events. It’s not time to show it publicly yet but, working on user accounts gave me an idea of how insecure a site can be when built by a beginner without any knowledge of SQL sanitisation.

It was this site that made me finally pick up Django, which I hoped would solve my security issues for me. While learning Django, I found out about Django-allauth, and the way it uses ORMs, which was heartening.

Last bit

I’ve learnt a lot. I can make web apps/websites in Flask, and I’m beginning to feel my way into Django.

I read that a lot of compsci grads can’t even code fizzbuzz. Does this mean I’m good enough for a job? I don’t know. I still don’t have the confidence to apply. I wish someone would tell me. It’s easy to say, hey, you can just ask. But more often than not, people tell me, yeah, ask me any time, and then they are way too busy to reply to me every time I ask. And online forums can be untowardly harsh to beginners, which is hardly good for anyone with anxiety issues.

I also wish I’d had teachers who guided me. But, I suppose, I go it alone as usual, and hope for the best. It’s really slow. But I guess, I’m getting somewhere?

I’ve started on JavaScript too. ūüôā

Quick Word on Jobs

Quick Word on Jobs

I picked code up in part to get a better paying job than anything on offer in the arts. Now I have Python, Flask, and SQL with me. However, after going through job sites for a few days, I’ve discovered that most jobs are for front end developers with HTML5, CSS, and Javascript.

There is a lot of demand for Javascript using AngularJS, React, NodeJS, etc. So, the fastest way to get a job is to pick up front end web dev/design skills.

If you stick with Python and want to do some back end work, you’ll need Django, and NoSQL, typically MongoDB. Not Flask. Exceedingly few¬†hiring companies use¬†Flask.

Ruby on Rails appears quite a bit too. Also a lot of demand for UI/UX. But that floats into a more distant skill set.

Attempting to Learn Flask, Part 1

Attempting to Learn Flask, Part 1

I think this might be a series on how I learn Flask. I don’t know if I’ll succeed or fail yet at learning it. I’ll try and track my progress or the lack of it, and hope I don’t run out of steam.

So, I’ve been trying to learn the framework for a while now. The first time I tried was two or three years ago when I first started Python. As you might guess, it was totally the wrong time to start. Now I have a better handle on Python, and I thought about a week or so ago that I’d try again.

Deciding on Flask and Not Django or Bottle or Whatever Else

As it happened with the first time, googling turned up a lot of “should I learn Flask or Django” results and I wavered between the two, and installed both, and then once again decided to focus on Flask.

The decision isn’t that simple to make because lots of people say different things, but I’ll boil them down to two main factions.

One faction says to learn Django because it is sort of standardised. It’s like a set meal. You get burger, fries, soft drink, all together in a sensible, familiar package. As a result, it is also complicated and has a steep learning curve. But, community support is waaaaaaaaaaaaaaaay better than Flask’s! That counts for a lot.

The other faction says to learn Flask because it’s flexible and easier to learn. That means, though, that it’s not like a set meal at all. What it looks like is someone giving you all the raw ingredients of the meal and you have to put it all together yourself. So, you have to learn how to build a burger, and then how to make fries just the way you like, and then the soft drink. People say it’s not that hard, but the people who say that seem to mainly be experts, or those with computing backgrounds, or those with money for boot camps and advisors and teachers. Obviously, it’s not hard for them. Plus, community support is very thin compared to Django’s.

There are other factions, but these are generally the two loudest voices. After a lot of going back-and-forth, deciding, re-deciding, indecision, paralysis, doubt, existential crisis, I settled on Flask because a few people said it’ll be easier to learn Django after Flask. And more importantly, I needed to focus¬†somewhere, and it might be easier to start with what other people claim is easier.


Once beginners start asking questions like, how do we use Python on the web, the answer is bound to be: learn a framework. Remember, at this point,¬†beginners haven’t much of an inkling what Flask is, or even what a web framework is. Everything we read about frameworks online seems to make sense, but only in a sort of hazy, somewhat figurative manner. In other words, it’s likely that experts think they’ve explained it clearly, and beginners think they sort of understand, but there’s a massive gap between the two, and few people see it. Nonetheless, the only way is forward, right?

But the jump from basic/intermediate Python to learning a framework like Flask is HUGE. This will become very apparent when beginners start on the tutorial everyone suggests: Miguel Grinberg’s Mega Flask Tutorial.

This tutorial is spectacularly bad for beginners.

The tutorial doesn’t explain a lot of things, including precisely¬†where Python code connects with its equivalents in the HTML templates. You might say that should be obvious. But it’s obvious for people with a much larger store of knowledge than beginners.

At the same time, the tutorial involves a lot of code connected to each other across many files, in ways that we cannot understand at a glance. Some functions require ostensibly unrelated code inserted into views.py, models.py, config.py, and one or two others. That’s super confusing for beginners.

By the time we reach the part where we write the login page, we give up. Especially because at that point, we have to decide between the chapter from the older tutorial, and the newer one on OAuth that isn’t very clearly connected to the older tutorial. And if we screw either up, we don’t know how to continue with the rest of the mega tutorial.

It Gets Cloudier

At that point, we start looking for other tutorials. A bunch of these want us to start on Droplet (we have to pay for it), Heroku, or other similar services. Only here do we usually get the first mentions of Flask being problematic on Windows, and we’re not sure what that means.

So, we’re stuck. We don’t want to pay for Droplet. And we are scared that if we go with Heroku, we might go off on another difficult tangent with more difficult stuff to learn. We begin to wonder if there’s another tutorial, or if there are ways to work around this.

What do we do next? I don’t quite know yet.

How to Learn Flask

Evidently, there is a big portion of knowledge missing between basic/intermediate Python and Flask. But I don’t know what it is and nobody seems to proffer good estimates. So, I’m going to try two methods people have intimated in the usual overly optimistic terms. “Just do it!” doesn’t cut it, guys.

The first is the project-based method: I know I want to build a chat website, and I have a rough design for it. I know I want to have some development for ecommerce under my belt so I can build a career from it. So it makes sense to start with these two.

The second is to try and break up Flask into small and manageable parts and learn those parts. This is somewhat problematic. People say you can do anything with Flask. That means we don’t know where to begin. It’s like saying, you can do anything you want, so what do you want to do? Well, I want to solve poverty. Maybe I want world peace too. But what are the small tiny manageable parts to those problems? It might be impossible to see. We might get there by iterating through lots and lots of smaller and smaller problems though.

You see how unhelpful it is as a pedagogical guide to tell beginners you can do anything with Flask and then send them to difficult tutorials?

In part 2, if there is a part 2, I will talk about how I got on with this.