Jeff Elkner's Django Girls Tutorial Blog


We're Hosting a Workshop!

Lena Bolz, Monica Lozano and I applied to host a Django Girls workshop, and this past Wednesday we found out we had been approved.

On Saturday, February 22nd, 2020, we will have our first Django Girls workshop at the Arlington Career Center. To help us begin to get ready, I started using the Django Girls Tutorial with my computer science classes today.


Updating My PythonAnywhere Application

After making changes to my local version of this blog app and pushing the changes to Github, this process will update the instance on PythonAnywhere:

  1. Open a console on PythonAnywhere and run:
    • $ workon
    • $ cd
    • $ git pull
    • $ python collectstatic
  2. Click on the Web link on the main menu, and then click the green Reload button.


Formatting Datetimes and Adding HTML in Blog Posts

Since I have some background in HTML and CSS, I am following this tutorial without using Bootstrap, instead focusing on using semantic HTML. I wanted the simplest way to using HTML in the blog posts, which turned out to be this:

{% autoescape off %}{{ post.text }}{% endautoescape %}

In the Published paragraph of the blog posts, the published date and time should properly be in a <time></time> element with the datetime attribute properly set. I was able to do that with:

<p class="published">Published:
<time datetime="{{ post.published_date|date:'Y-m-d H:i:s' }}">
{{ post.published_date }}</time>

Resources I found helpful in figuring this all follow here:


Creating a superuser

Creating a superuser in Django which has access to all parts of an application, including the Django admin interface, is done with:

(venv) $ python createsuperuser

This user object can then be accessed programmatically with:

(venv) $ python shell
>>> from django.contrib.auth.models import User
>>> admin = User.objects.get(username='admin')

This assumes admin was the user name chosen for the superuser. Any valid username would work.

That's it for creating a superuser.


Using the Django Interactive Shell

This is post was made to my blog from Django's InteractiveConsole. I started it by running 'python shell' at the bash shell from within my virtual environment. I could then interact with my Django app using commands like the following:

from blog.models import Post
from django.contrib.auth.models import User

author = User.objects.get(username='admin')
    title='Using the Django Interactive Shell',

This is really cool!


First Post

This is the first blog post made with the Django Girls Tutorial blog.