Including an extra button in a crispy form

I’m a big fan of using crispy forms with Django. In fact, since doing the Django girls tutorial, I don’t think I’ve made a form manually.

And, until now, I haven’t been super critical of aesthetics. Now, however, I’m updating the look of the worksheet generator and moved the login to a modal. Doing that, I thought… “Hmm, wouldn’t it be nice if the ‘reset password’ button was in a button group with the login button?

It turned out to be a bit of a challenge for me, and I couldn’t find anything on it specifically, so here’s what I did:

loginModal
The goal — Doesn’t that look nice?
oldLogin
What I had before. Too much screen real estate.

Functionally, it’s not a big deal, except that I’m using button groups more and more in the site in general, and why not use one here?

However, the old way I was rendering the form wouldn’t work. The crispy FormHelper object rendered the form so completely that I couldn’t get at the login button, much less wrap it together in in a button group.

Of course it was possible, but the solution turned out being telling crispy forms to let me create my own form tag:

# forms.py

class LoginForm(forms.Form):
    username = forms.CharField(label='Username:', max_length=100)
    password = forms.CharField(label='Password:', widget=forms.PasswordInput(), max_length=100)

    def __init__(self, *args, **kwargs):
        super(LoginForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = False

The self.helper.form_tag = False bit turns off the form field.

Then, in the template rendering the form, I had to make some changes. To be honest, I should say that I took the easy way by having crispy forms render the form tag, and then copied that.

template
WordPress didn’t want to display this, so this seemed the easiest thing to do.

Initially, I did this without adding type=”button” to the second button in the group and, for reasons I don’t understand, both buttons functioned at a submit button. Obviously, that wasn’t ideal, and adding the extra type=”button” made it work.

It’s worth pointing out that I never (or, not yet) removed the old …/login.html page that rendered the form before. Nothing links to it, so I doubt anyone will ever hit it. But, if they did, the form would be broken because I didn’t update that template to include a form tag.

Advertisements

The Art of Acquiescence

This is another chapter reflection in my The Obstacle is the Way project.


Be guided by the fates

This chapter starts with a quote from someone named Cleanthes, who I know nothing about. But, I’m a sucker for mythology so I liked it:

The Fates guide the person who accepts them and hinder the person who resists them.

-Cleanthes

The rest of the chapter was about the value of being guided by the fates. It began with the story of Thomas Jefferson and the speech impediment he was born with. In an era when oratory was the accepted route to politics, it seemed like an insurmountable obstacle, but Jefferson wasn’t deterred. Instead of going the Teddy Roosevelt route and deciding to overcome his challenges, he decided to ‘go with the flow’ and instead focus on his writing.

The rest, as they say, is history.

Then, the chapter offers a really interesting definition of genius:

“True genius,” as the infamous Dr. Samuel Johnson once said, “is a mind of large general powers accidentally determined in some paticular direction.”

I like the idea that the ‘particular direction’ we take is at least in part accidental. (It matches my experience of life.)

And then Ryan Holiday gives a great example:

If someone we knew took traffic signals personally, we would judge them insane.

Yet this is weyactly what life is doing to us. It tells us to come to a stop here. Or that some intersection is blocked or that a particular road has been rerouted through an inconvenient detour. We can’t argue or yell this problem away. We simply accept it.

The chapter continues for a few more pages, but that’s the meat of it right there: learning to accept the fates can mean accepting that your path in life is sometimes more accidental than you hoped for, and that events that you can’t change are to be accepted.

I like the comparison with traffic signals, because it’s easy to relate to. We’ve all driven detours and still arrived at our destination. And, we’ve also seen the traffic signals and decided “you know what, I can go there another time.” (That’s how I interact with major road closings downtown.)

When should you bend?

The fun of reading the book out of order now is that I get to directly contrast this chapter with the chapter on the Inner Citadel. To go from holding up Teddy Roosevelt as an example of will triumphing over circumstances to Thomas Jefferson as an example of will bending with the circumstances, it’s logical to ask yourself: when should I bend? When should I invest my will in defying circumstances?

It’s easy to complain that Holiday doesn’t go into specifics. (He almost never does.) But I think that the two examples and the traffic metaphor are enough to extrapolate some thinking.

First, it should be pointed out that Teddy Roosevelt didn’t randomly decide to overcome his asthma. He had the advantage of his father’s wisdom which said to him: I think you can do it. I know it will be hard, but it seems doable. Further, it seems like the only route to where you’re destined to go.

Second, Jefferson didn’t have that level of wisdom at his disposal (in the anecdotes. I don’t know anything about his actual family.) Today, perhaps they’d have organized a speech therapist for him and he’d be the prequel to “The King’s Speech.” The fact of the matter is: nobody could tell Jefferson if there was a route open to him that involved investing a lot of willpower in overcoming his speech impediment. (And, in the other example of Edison’s difficulty hearing, we know there’s not a solution).

My point is this: it takes a certain degree of wisdom to know what’s available.

Third, the car metaphor is apt, because it lends itself well to the idea of ‘goals as destinations.’ We’re trained to think that a car is the fastest way to get somewhere. The longer you live somewhere — the more wisdom you gain about a place — the more you realize that often walking, a bicycle, or public transportation are faster than a car. There are times when it makes more sense to get out of the car and to put in the ‘hard work’ of walking, because that’s the smartest thing to do.

Returning to the earlier examples: Roosevelt and Jefferson both saw a mountain between themselves and their destination. But Roosevelt had the advantage of his father’s wisdom who said “Teddy, the only way over this mountain is to climb it. It’s going to be difficult, but I think you have what it takes. Further, you’ll be happier on the other side and glad for it.”

Jefferson, on the other hand, had to reach a conclusion on his own and it seems to have been something more along the lines of “I don’t know if I can get over this mountain. Nobody ever has. But, I think I see a pass further along in that direction. Better to invest my energy into getting into and through the pass than in an attempt that might never work.”

They both would up where they wanted to go, and they both (probably) took the route that was right for them.

Conclusion

When I started writing this, I didn’t expect there to be so much of my own thought in it. (It’s part of why I write, I guess.)

The thing is: it’s easy to analyze the two stories and their well-known outcomes and say “Teddy was right to draw on the strength of his Inner Citadel, and Jefferson was right to be guided by the fates.” But, when we see our own mountain in front of us, how can we know whether we should get out of the car and climb, or start moving laterally in search of a pass?

The answer seems to lie in Roosevelt’s father: we need wisdom. We need both to learn what we can — what have other’s accomplished? what is possible? — and to have our own council of the wise that can I say to us “I think that can be done” or “that’s the fates at work, there’s no sense in railing against them.”

And, of course, there’s the additional challenge of developing the wisdom needed to recognize that wisdom. But, I don’t know if I have an answer to that.

The mythos of the ‘finisher’

I’ve said before that I like the title of ‘maker.’ More than teacher, I think that’s the title I’d like to go by. Teaching is a skill I have, one I can reliably trade for money, but it’s not who I am. Making is a skill I want to have, something I’d like to trade for money, someone I want to be.

My derivative creativity

And, in fact, I think I’m blessed with an ability to see past “what is there” to “what could be.” A lot of what I think of is derivative (in the sense that “the Tinder of apartments” would be a derivative app) but nonetheless creative. (Fun fact, I wrote that first and then googled it. Of course, the tinder of apartments is a thing.)

I don’t think derivative is bad. After all, schools began as “a house, but for learning.” If you realize that there’s something missing in the world, there’s nothing wrong with using the vocabulary of what is to describe it.

Finishing vs making

A friend of mine and I once started work on an awesome collaborative novel. Eventually, he bailed on the project, telling me “we’re better at starting projects than at doing them.” That comment has haunted me, because it was true.

I start a lot of things (see the Papa’s Work app idea — which remains a good idea) but there are so many things.

When I finally got my worksheet generator off the gound and running, I felt a rush of exhilation. My understanding of who I am changed. I made something. I was a maker.

That friend was wrong. (I doubt he remembers the comment, or could know how much it bugged me.)

But the goalposts had moved.

Yeah, I made a webapp and used it to prepare my lessons. But nobody used it, except me. You might think that should be enough, but if people tried it and said “Toby, it’s not for me” I’d get it: I had an idea that only I liked.

That wasn’t the situation. I’d made software that only I could use. (I learned that by sharing the link with colleagues and realizing they had no idea what they were supposed to do.)

Software that only I could use would be fine… Except that wasn’t how it was conceived. It wasn’t finished. I’d become a maker — I could have an idea and work on it long enough to actually produce something — but I wasn’t yet a finisher.

I aspire to be a finisher

So, I’ve decided to become a finisher. The worksheet generator will be finished. When it does, expect the celebration to be great.

Before that, the The Obstacle is the Way project will probably reach its conclusion. (That’s part of why you see so many posts on it here.) It’s a ridiculously simple project, but it’s a goal I’ve set for myself — and something that’s brought me benefit — and the new, finishing me is going to see it through to the end.

Don’t worry, when I think I’ve earned the title of ‘finisher,’ I’ll claim it here. You’ll know.

In pursuit of failure

“Fail forward” is a sort of mantra in the startup world. (Or, that’s how it seems, watching that world from the outside.) The idea, as I get it, is that you have to fail often and fail fast, as long as you learn from your failures and get up meaner and leaner for your next adventure.

That’s not what I’m talking about here.

I guess that what I mean could be called muscle failure. But I think it’s more than that.

Back it up a bit

I guess that today’s The Obstacle is the Way chapter on Building Your Inner Citadel got me thinking about something that haunts me periodically: my own troubled relationship with willpower. And, perhaps, my weird linking of willpower with manhood.

This will be a disjointed blog post.

The fact of the matter is, I don’t know if I’ve ever reached muscle failure. I mean, I’ve collapsed after a set of push-ups. But, as I stood back up, I’ve been haunted by the fact that I might have been able to do a few more push-ups, if I’d really tried. After all, push-ups seldom are connected to any real consequences.

Fun random aside:

One of my father’s favorite stories from the Army was in some training camp or other where he was the platoon leader, and there were only enough truck to transport two of the three platoons back to the barracks. One platoon was going to have to march.

The way the seargents on the scene decided to allocate the trucks was to have the platoon leaders compete doing push-ups. “I knew I didn’t have to win,” my father always says in this story, “I just couldn’t lose.”

According to the legend, he did over a hundred push-ups in this story. I’ve never done that many push-ups, and I often wonder if I would have the mental fortitude to really push myself, if I had to.

So, I wonder, is there a way I can engineer my own muscle failure. Can I set myself up to try hard at things and fail, knowing I’ll come away stronger and wiser? (Or with a reinforced Inner Citadel, whatever that means.)

I don’t know.

The Army Combat Fitness Test

Part of what’s got me thinking like this is the news that the U.S. Army is introducing a new physical fitness test. Up until I stopped doing sit-ups (word on the street has it they’re bad for your back) I’ve been silently measuring myself against the existing Army Physical Fitness Test. After all, my first encounter with the idea of ‘minimal fitness’ was with the Army, and it’s nice to know (or think) “I could check all those boxes. I am fit.”

The new test may or may not be an improvement over the old test. What it is, though, is a departure from the days when I could do the exercises at home and say “Yup, that was enough push-ups.” or “I smoked my old two-mile run time.”

Conclusion

I don’t know if there is a conclusion. The point is, I wonder about my ability to push myself until my body simply doesn’t have more to give. I get that I’ll probably never need to do that.

But I want to know that I can. And I don’t know how to teach myself that.

Build Your Inner Citadel

In my continuing The Obstacle is the Way project, I’m writing on this chapter of the book.


In another chapter that provides a great tip, but doesn’t explain how to follow through with it, Ryan Holiday begins this chapter of The Obstacle is the Way by referening my (sometimes) favorite American president, Teddy Roosevelt.

[speaking of asthmatic, weak young Teddy] One day his father came into his room and delivered a message that would change the young boy’s life: “Theodore, you have the mind but you haven’t got the body. I’m giving you the tools to make your body. It’s going to be hard drudgery and I think you have the determination to go through with it.”

You’d think that would be lost on a child, especially a fragile one born into great wealth and status. But according to Roosevelt’s younger sister, who witnessed the conversation, it wasn’t. His response, using what would become his trademark cheerful grit, was to look at his father and say with determination: “I’ll make my body.”

I love Theodore Roosevelt for a number of reasons, but I think his relationship with manliness is problematic. (I read an article that suggested he may have driven a son to suicide with his expectations.) Still, his determination is enviable, at the least.

Moving on philosophy, Holiday talks of developing “mens sana in corpore sano — sound mind in a strong body,” and matches this to what stoics called their “Inner Citadel, that fortress inside of us that no external adversity can ever break down.”

Then, the narrative returns to Roosevelt:

To Roosevelt, life was like an arena and he was a gladiator. In order to survive, he needed to be strong, resilient, fearless, ready for anything. And he was willing to risk great personal harm and expend massive amounts of energy to develop that hardiness.

And all that is great… but that’s where the chapter winds down. (There’s one last quote that I’m saving for the end, as seems to have become my tradition.)

And, as a guy who flirts with an obsession with fitness, it’s easy for me to think that I’m moving down the right path. But, I don’t know. Holiday doesn’t end the chapter with his list of “Ten Things You Can Do Today to Become the Architect of your Own Inner Citadel” and I’m left with a list of questions:

  • Should I invest more energy in meditation?
  • Do the things I do to practice practice help?
  • What about cold showers: they certainly demand willpower, do they also strengthen it?
  • Does enduring voluntary adversity help when involuntary adversity comes knocking?

There aren’t answers, and I’m left reaffirming my commitment to fitness and “making the most of my time.” (Whatever that means.)

However, I did mention that there is one last great quote. It’s as close as Holiday comes to direct advice in this chapter, and I like the first sentence enough to maybe write it on my wall:

The path of least resistance is a terrible teacher. We can’t afford to shy away from the things that intimidate us. We don’t need to take our weaknesses for granted.

Some Coding Goals

Setting my own goals

It was not a super-productive summer for me, coding-wise. However, as I get away from ‘vacation-mode’ and back to ‘real life,’ in addition to improving as a teacher (more on that in another post), I want to improve as a coder.

Here’s the thing: There are a million ways to improve as a coder. And, I’m sticking to the ‘hobby coder’ label, so I don’t feel compelled to even try an know everything about coding, or even a specialization under the ‘coding’ header.

My task: is to be able to do the things I want to do, nothing more, but also nothing less. (To be honest, it will always be something less — I have an active imagination for what’s possible.) Now though, what I’d like to do is to make the things I make seem more like a ‘web application.’

What’s a web application?

The short answer is: it doesn’t matter. As a language teacher, I’m a big fan of the idea that words only mean what you and the person you’re speaking to understand. And, when I say web application, I mean it in contrast to a ‘web page.’

To me, a web page is static: Some guy (me) writes a bunch of stuff, takes a bunch of photos, makes a video, maybe, and puts it online. The web page is your chance to interact with what I’ve made, on my terms.

A web application, on the other hand, is magic. Sure, some guy (me) made it, but it’s a tool that I get to pick up and use how it best fits in my life. A web application is my chance to take something algorithmic I’ve made, and let you run with it.

Don’t you already do that?

To be fair, yes, I think that Dynamic EFL already qualifies as a web application. But, it doesn’t feel like it yet. It feels like a series of web pages that the user moves through, ending with a PDF, the most static document format of all time.

It’ll always end with a PDF, because the whole idea is that it’s supposed to be hidden. The learner isn’t supposed to know you used a ‘tool.’ The learner might hear the word ‘tool’ and think ‘shortcut.’ The whole idea is that the learner thinks “wow, the teacher invested time in me. I’m getting my money’s worth.”

So, maintaining the PDF format at the end, the way I see to make it feel more like an application is to make better use of transitions between pages and modals (the ‘foreground’ pages that open ‘over’ the rest of the page — logins are often done in modals).

The best web applications — gmail, Google calendar — don’t feel like pages at all. It feels like you enter an address into your browser, and then you interact with an application. That’s what I’d like to do.

A good argument for it

First, I rationalize it would help make what I do clear in comparison to what teachers are already paying for — static resources presented on web pages.

Second, it’s a sales point. Done smartly, the transitions and ‘web app experience’ simply feels more ‘modern.’ It helps to explain why I’m taking money.

A roadmap

I don’t have a roadmap in the traditional sense. That’s where this little goal-setting exercise breaks down. I’ve started experimenting and I’m finding it pretty hard. I have used JavaScript to dynamically change content on a web page, but I haven’t made the animation part of that work, and I haven’t been able to load a new django view into one <div> of a page.

So, I guess I have my work cut out for me.

The plan, now, is to leave Dynamic EFL how it is as I begin attracting beta testers. Instead, I have a new project idea that I want to start from scratch as a web application (using Google APIs, no less!) (more information on the actual project in a future post). Then, when that’s working, I’ll be able to apply lessons learned to Dynamic EFL.

Wish me luck.

Seize the Initiative

In my continuing The Obstacle is the Way project, this is the chapter I chose to write about today.


This chapter was short and basically boiled down to “when life has you on the defensive, go on the counter-attack.” But, there were a few quotable moments, beginning with the opening quote:

The best men are not those who have waited for chances but who have taken them; besieged chance, conquered the chance, and made chance the servitor.

-E. H. Chapin

Isn’t that great? I want to besiege chance.

Another great line is this, from Ryan Holiday himself:

If you think it’s simply enough to take advantage of the opportunities that arise in your life, you will fall short of greatness. Anyone sentient can do that. What you must do is learn how to press forward precisely when everyone around you sees disaster.

Aside from the truth of it, I would probably love any sentence that threatens me with ‘falling short of greatness’ and encourages me to be something more than ‘merely sentient.’

Something I like about this chapter is that, aside from the stories (Barack Obama’s campaign and the WWII German general Rommel), there are examples of how this might work, and they aren’t simply “working through the pain.”

Ryan Holiday suggests looking at the catastrophes in your life and seeing what they offer. If a relationship has ended, you have more time to work on projects. If you’re in bed recovering from something, you can write. That sort of thing.

I’d like to think that I’m the kind of guy who does that. But, maybe I’m the kind of guy who plans to do that, but then just sinks into depression when life hits him hard.

After reading Love Everything that Happens, I’ve got a lot of mileage out of thinking “this is what I wanted to do, I get to do this now,” whether it’s freezing cold campground showers or trying to do pushups to muscle failure. I think that, teaching myself to think, “this is an opportunity to go on the counter-attack” could be just as valuable.