Skip to content
Patrick Michaud edited this page May 24, 2013 · 3 revisions

This is the recommended approach for installing Yarn. The use of virtualenv is optional, but helpful.

Prerequisites

  • A Python installation (2.5 or greater)
  • pip or easy_install

Step-by-step

  1. If you don't have it already, install virtualenv:

    $ pip install virtualenv
    

    if you don't have pip, you may be able to:

    $ easy_install virtualenv
    
  2. Clone the yarn repository

    $ git clone git://github.com/vegitron/yarn.git
    

    or if you will be editing files and committing:

    $ git clone git@github.com:vegitron/yarn.git
    
  3. Turn yarn into a virtualenv:

    $ virtualenv yarn
    
  4. Activate your virtualenv:

    cd yarn
    source bin/activate
    
  5. Install required Python packages with pip:

    $ pip install -r requirements.txt
    
  6. Create a django project in the yarn dir:

    $ django-admin.py startproject project .
    

    That '.' at the end is important!

  7. Modify at least the following settings in project/settings.py:

    • DATABASES
    • INSTALLED_APPS (add 'yarn', 'compressor', 'templatetag_handlebars')
  8. Map urls to the yarn app by adding the following to urlpatterns in project/urls.py:

    url(r'', include('yarn.urls')), 
  9. Configure authentication

    You can use any authentication method here: https://docs.djangoproject.com/en/dev/topics/auth/

    I find the remote user middleware the easiest way to get started though. To do that, add this to your project/settings.py file:

In MIDDLEWARE_CLASSES, after 'django.contrib.auth.middleware.AuthenticationMiddleware',: 'django.contrib.auth.middleware.RemoteUserMiddleware',

Add this below MIDDLEWARE_CLASSES:

```python
AUTHENTICATION_BACKENDS = (                                                     
    'django.contrib.auth.backends.RemoteUserBackend',                           
) 
```
  1. Create your database:
```
$ python manage.py syncdb
```
  1. You should now be able to run your development server:
```
$ python manage.py runserver
```

If you're using the remote user middleware, run your development server like this:

```
$ REMOTE_USER=vegitron python manage.py  runserver
```

Replacing vegitron with your desired username.

Clone this wiki locally