- virtualenv
- python == 2.7.10
- Pillow 3.2.0
pip install Pillow==3.2.0
-
Set up a virtual environment
-
Create a virtual environment
virtualenv swiftbrowserenv cd swiftbrowserenv
-
Activate the virtual environment
source bin/activate
-
-
Download and install
git clone git://github.com/bkawula/django-swiftbrowser.git cd django-swiftbrowser python setup.py install
-
Setup your Django project. Django projects are made up of modules which are called apps.
-
Initiate a new app called
myproj
(or your name of choice). It will be the main app within your Django project that "imports" swiftbrowser as an app.django-admin.py startproject myproj cd myproj
-
Copy the sample settings.py file to the newly created app.
cp ../example/settings.py myproj/settings.py
-
Adopt
myproj/settings.py
to your needs, specifically settings for Swift such asSWIFT_AUTH_URL
,SWIFT_AUTH_VERSION
,BASE_URL
andSTATIC_DIR
. The following is an example used in development:SWIFT_AUTH_URL = 'https://yourswiftserver.com:5000/v2.0/' SWIFT_AUTH_VERSION = 2 # 2 for keystone BASE_URL = 'http://localhost:8000' STATIC_DIR = 'swiftbrowser/static/'
-
Create a directory for Django to put it's database.
mkdir myproj/database
-
In this step, we make the swiftbrowser app available to the main app "myproj". This is done by making a symlink to the swiftbrowser folder.
ln -s ../swiftbrowser swiftbrowser
-
As mentioned earlier, "myproj" in a way "imports" swiftbrowser as an app. This is done by adding it into the
myproj/urls.py
file. This is Django's file to route requests to different functions.-
Update the
myproj/urls.py
by adding the following to the top of your file:import swiftbrowser.urls
-
Edit your
urlpatterns
variable by addingurl(r'^', include(swiftbrowser.urls))
. Once done, your urlpatterns will look something like this:urlpatterns = [ # Examples: # url(r'^$', 'myproj.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^', include(swiftbrowser.urls)), # Add this line ]
-
-
-
Setup the Django app for development.
-
Django manages database queries through classes (in
models.py
). The following step ensures that any database requirements have been applied to the database. Swiftbrowser doesn't use a database as it's simply a gateway to a Swift cluster but for development purposes this step is required. You'll be asked to create an admin user but you'll never need to use it.python manage.py syncdb
-
Static files across all the "apps" in this django project are collected to one place to be served out.
python manage.py collectstatic
-
That's it! The following will run the development server:
python manage.py runserver
-
If you're planning to do any front end changes, specifically any CSS changes, be sure to read the Compiling the CSS (Foundation).
At Scholars Portal, we have access to a paid library of icons from Glyphicons. Our copy is held on gitlab - so ask someone on the systems team to give you access to the "fonts" repository under "Bartek Kawula". To add this library to the repo, follow these steps:
-
Change directories to your django-swiftbrowser repository.
cd django-swiftbrowser
-
Initalize the submodule within the django-swiftbrowser repository.
git submodule init
-
Pull in the files from the repository.
git submodule update
-
Move these new files into the static directory.
python myproj/manage.py collectstatic