A Foundation Theme for Django Projects¶
A Pinax theme based on Zurb Foundation. Foundation is a popular CSS framework that is light weight, but includes all the basics such as; a responsive grid, forms, dialog, navigation tabs, buttons, typography and so on. You can read more about the ideas behind Foundation and how to use it for rapid prototyping in this article.
This version supports Foundation 5¶
- We support the latest version of Foundation (5.2.1)
- Updated the documentation
- The project now supports the
--template
argument fordjango-admin.py startproject
command - Removed more
Pinax 0.9
dependencies however, the project should still be compatible with the other apps in thePinax
eco-system such as django-user-account
Getting Started¶
Start by creating a new virtualenv for your project and install Django 1.6.2
mkvirtualenv mysite
pip install Django==1.6.2
To use create a project based on the zero project run
django-admin.py startproject mysite --template=https://github.com/chrisdev/foundation-project-zero/zipball/master
This will create a new Django project in the mysite directory with:
- An apps folder for your internal apps
- initial data (for handling
sites.Site
model)- Requirements files for use with pip
- A home for your site’s static files
- A set of templates designed to work with the foundation theme
Finally install the requirements, sync your database and start the test server
cd mysite
pip install -r requirements.txt
python manage.py syncdb && python manage.py runserver
The account starter project provides all the features of the zero project in addition to incorporating features to support django-user-account.
django-user-account is an extremely useful Pinax
app that
works in conjunction with django.contrib.auth to
take your Django project from having simple log in, log out and password reset
to a full blown account management system. To create a project based on the
account starter project
django-admin.py startproject --template=https://github.com/chrisdev/foundation-project-account/zipball/master mysite
Templates¶
Your own templates should normally inherit from site_base.html
.
You should provide your own “footer” template _footer.html
.
Also change the Site name by editing fixture/initial_data.json
.
You can also use the Admin app for this purpose.
The url name “home” should be defined as the homepage.
Upgrading From Previous Versions¶
To upgrade your site start by upgrading to the latest version on pinax-theme-foundation
pip install -- upgrade pinax-theme-foundation
The big change between Foundation 2 to 3 is the grid.
In Foundation 3 you no longer have to use .container
to define the grid. In Foundation 2 the grid was built around
*.container > .row > .columns*
. In Foundation 3
you now just need to use *.row > .columns*
.
In Foundation 3 padding and borders no longer increase
the width of an element,
they only go inward so for example in Foundation 3 .three.columns
always has a width of 25% with a 15px padding on the left and right.
You can find the Foundation 3 migration guide
here
The Details¶
Forms¶
This theme ships with a basic template tag for rendering forms that match the markup expected by foundation.
To style forms, add the following to the top of your template
{% load foundation_tags %}
and include your form using the following markup:
<form method="POST" action="">
{% csrf_token %}
<fieldset class="form-controls">
{{ form|as_foundation }}
</fieldset>
<fieldset class="form-actions">
<button type="submit" class="button medium radius nice"">Submit</button>
</fieldset>
</form>
Find more about foundation forms here .
Modal Dialogs¶
Reveal is foundation’s modal dialog The easiest way to use reveal dialogs with your pinax_ forms is to first create a separate template for the form as shown in this simplified example taken from the idios app.
{% extends "idios/base.html" %}
{% load foundations_tags %}
{% load i18n %}
{% block head_title %}{% trans "Edit Profile" %}{% endblock %}
{% block body %}
<form class="nice" method="POST" action="{% url profile_edit %}">
{% csrf_token %}
<fieldset>
{{ profile_form|as_foundation }}
</fieldset>
<div class="actions">
<button type="submit" class="button medium radius nice">Update</button>
</div>
</form>
{% endblock %}
In the template (idios/profile.html) where you to show the modal form, add the “reveal” class selector and give it an id (edit-profile-box) to the object which you want to fire the modal when clicked:
<a id="edit-profile-box" href="{% url profile_edit %}" class="button reveal">Edit profile</a>
The href {% url profile_edit %}
url will display the form.
Finally add the following javascript to the template.
{% block extra_body %}
<script>
$('#edit-profile-box').click(function(event) {
event.preventDefault();
var $div = $('<div>').addClass('reveal-modal').appendTo('body');
$this = $(this);
$.get($this.attr('href'), function(data) {
return $div.empty().html(data).append('<a class="close-reveal-modal">×</a>').reveal();
});
});
</script>
{% endblock %}
It should be noted that
Mobile Visibility¶
Zurb Foundation includes a series of visibility classes that allow you to hide or display content on various devices using ‘show/hide-for-x’ where “x” can be a xlarge, large, medium and small. For example if we include the following snippet on the line corresponding to the device that you are currently using will be displayed
<strong class="show-for-xlarge">You are on a very large screen.</strong>
<strong class="show-for-large">You are on a large screen.</strong>
<strong class="show-for-large-up">You are on a large or very large screen.</strong>
<strong class="show-for-medium">You are on a medium screen.</strong>
<strong class="show-for-medium-down">You are on a medium or small screen.</strong>
<strong class="show-for-small">You are on a small screen, like a smartphone.</strong>
Conversely including
<strong class="hide-for-xlarge">You are not on a very large screen.</strong>
<strong class="hide-for-large">You are not on a large screen.</strong>
<strong class="hide-for-large-up">You are not on a large or very large screen.</strong>
<strong class="hide-for-medium-down">You are not on a medium or small screen.</strong>
<strong class="hide-for-medium">You are not on a medium screen.</strong>
<strong class="hide-for-small">You are not on a small screen.</strong>
Will display the two lines corresponding to the devices that you are not using.
CHANGELOG¶
0.2.3 (2013/02/26)¶
Changes are mainly from our new contributor Justin Hamade
Updated all the foundation css classes and included support for the new icon fonts To create an icon apply the appropriate classes that match the icon you want to use.
<i class="foundicon-[icon]"></i>
Added demos from the ZURB playground, these make a nice visual test to make sure things were working:
Added all of the templates from http://foundation.zurb.com/templates.php
Removed minimized ccs/js in favour of using an inline compressor like django-pipeline. This is has currently been implemented in Account Template
Fixes for the orbit slider
0.2a2 (2012/11/02)¶
- Provide support for the –template for
django-admin.py startproject
- Removed
Pinax
dependency. Note it will still work with other pinax style apps such as django-user-account
0.1.7 (2012/10/18)¶
- This release supports Foundation 3.1 which includes features such as right-to-left language support, new UI Styles for Progress Bars and Image Thumbs, updated jQuery and so on, read more Foundation 3.1 here
- Replaced any of the remnants of our home grown Top Navigation menu with the Foundation 3.1 responsive Top Navigation bar
- Included Icon Fonts, Responsive Tables and SVG Social Icons which are not part of core release
- Lay the groundwork for supporting the –template flag on the django-admin.py start project in the next release
- Other Bug fixes.
0.1.6 (2012/08/02)¶
- We now support Foundation 3 so you can use features like new the new Top Foundation Nav bar
- Support for responsive tables
- Simplified the demo site so that its just the pinax basic site
- Removed support for responsive design patterns as these were not compatible with Foundation 3 release
- Updated documentation to reflect Foundation 3
- Numerous bug fixes.
0.1.5 (2012/06/08)¶
Improved top Navbar based on which is based on foundation’s top-bar branch .
Inclusion of zurb symbol icon fonts.
Inclusion of CSS to support the Responsive Design Patterns originally discussed by Joshnua Johson and implemented by Matt Reimer
Updated documentation and set up a demo site based on a Pinax basic project
Some reorganization of the theme_base.html including:
- Moved (where possible) the javascript to the bottom of the file
- Use the static template tag
- Using the static assets for released version of zurb-foundation 2.2.1
Fixed numerous bugs
0.1.4 (2012/03/004)¶
- Added the Fixed top Menubar
- Show active links on the menubar (Issue #14)
- Fixed the repositioning of form when timezone is changed on timezone page
- Removed unnecessary cancel button on the modal Profile form
- Updated the Foundation theme to Zurb Foundation 2.2.0
0.1.3b (2012/2/13)¶
- Added Mobile Login/Sign in functionality
0.1.3¶
- Initial release of pinax-theme-foundation