Recap of the October Pinax Hangout

On October 22nd at noon Eastern time we screencasted our third Pinax Hangout. Here’s a little recap for you.

The purpose of the Pinax Hangouts is to engage more with the Pinax community. We want to let you know what we are working on, answer your questions, and present demos of old and new apps and starter projects. Our host last month was Brian Rosner.

Brian talked about pinax-project-blog, an out-of-the-box Pinax starter project. If you’re interested in learning more about the different types of Pinax projects, watch the video of our August Pinax Hangout.

Installation and Setup

In order to install pinax-project-blog, you first need to create a virtual environment. Next install the Pinax command line tool, which allows you to quickly start Pinax starter projects:

pip install pinax-cli

Now start your Pinax blog by typing pinax start blog myblog into the terminal. myblog is the name of your blog, you can however give it a different name if you like.

Afterwards you need to install the requirements pip install -r requirements.txt and migrate the database python manage.py migrate. This will set up sqlite by default. If you now run the server python manage.py runserver, open up your browser, and go to http://127.0.0.1:8000/ your blog should be up and running.

Before you can create anything on the blog you will have to create a user account. In order to do so you need to create a superuser first, which will give you access to the django-admin. Type python manage.py createsuperuser into your terminal. You will then be asked to enter a username, email, and password. Next run the server again, go to http://127.0.0.1:8000/admin and enter your username and password you just created. You have now access to the django-admin and should be able to see the groups, users, blog app and django sites.

Customizing your Blog and Adding Content

So far the site name of our blog is example.com. We want to change that and we can do so in django sites. Go to django sites, and change the name from example.com to myblog and myblog.com, then save your changes. When you open the site in your browser again, your site should now be called myblog.com. You can also add more users to the admin, when you click on users.

When you look at your blog, you can see that it has the ability to section your blog posts out into sections. The section called “all” is the default section. When you add a new blog post in the django-admin, you can also create a new section. You could for example create a section called “games”. Next type in the title of your blog post, the slug will be created automatically, and add a teaser and blog content. The teaser is what your reader will see when they click on the site listing all your blog posts. Please note that pinax-project-blog uses Markdown. When you created your blog post, you can then save it as a draft first. pinax-project-blog gives you the ability to share a draft URL with other people so they can give you feedback on your blog post before you publish it. If you want to publish your blog post, click on “published” and you will now see your blog post under the “games” section of your blog.

As you can see, there are a lot of things you can do with pinax-project-blog without even opening up a text editor and touching the code.

On the blog homepage however it shows you that if you want to modify things, you need to go to pinax/blog/blog_base.html inside of the templates directory. This particular template gets inherited by a lot of other templates so making changes to just this one template is very powerful. If you wanted to change your blog description for example, you would remove lines 15-17 in pinax/blog/blog_base.html and add your own description, for example “My name is Brian”. Save the changes, run your server and open up your blog in the browser, and you can see that your blog description was updated.

Integrating Analytics

You might want to integrate Google Analytics or a different analytics service like Mixpanel into your blog. We can do that with the metron app, which currently supports Google Analytics, Mixpanel, gaug.es, and Google AdWords Conversion Tracking. Install metron by typing pip install metron into your terminal, and add it to your INSTALLED_APPS in the myblog/settings.py file. There are different types of settings available. For a full list of settings, please visit the metron documentation.

Set up your metron settings by adding the following code to myblog/settings.py:

METRON_SETTINGS = {
    “google”: {
    1: “ ”,
    2: ” ”,

    }
}

The values you would supply for each service and SITE_ID node is the identifier code for that service. If you don’t have a Google Analytics account yet, follow these instructions and set one up.

Inside of _scripts.html we have the JavaScript while which is specific to our site. We want to bring in the analytics tag so we add {% load metron_tags %} on line 1 and {% analytics %} on line 3. The analytics template tag provides the integration point between the settings we just set and the different providers. If you now run the server, go to your blog, and right click on “show page” it will show you the Google Analytics. Alternatively you can type http://localhost:8000 into the terminal and it will show you the Google Analytics as well. You can of course use other providers through metron if you don’t like Google Analytics.

If you missed our October Pinax Hangout you can watch the video here

If you have any questions, please post them in our Pinax project Slack channel. No matter if beginner, or experienced, we want to help everyone!

Our next Pinax Hangout will take place on Thursday, November 19th at noon Eastern time. The topic will be announced soon. We hope that you will join us for our November Hangout!