How to Pass Additional Variables in Template when using Django Generic Views

Published / by chris / Leave a Comment

We’ve all done this before. We learn about class-based Generic Views in Django and we want to use them immediately in our code. Without reading all the way through the documentation, you make the switch. Suddenly, you’re not really sure how to add additional data to your templates. Maybe class-based Generic Views aren’t really what […]

Use a Template Filter to Nest a Context Variable Inside of a staticfile Template Tag

Published / by chris / Leave a Comment

You have a variable in a template that holds a filename. Then, you want to pass the variable to your template so that you can put the filename in an <img> tag and render it from staticfiles. You try doing something like this: <img src=”{% static ‘mysite/{{filename}}’ %}” width=”100″ height=”100″ /> However, this doesn’t work […]

What do you do when ‘makemigrations’ is telling you About your Lack of Default Value

Published / by chris / Leave a Comment

So you added a few fields on a model. You’re happy about the new model fields and you’re excited to deploy it to your server. You throw the following into your commandline. $ ./manage.py makemigrations Despite your giddiness that people will be working on your new models and you’re going to impress your boss and […]