Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I install Twitter Bootstrap for Django - main or static folder?

I'm new to this, and experimenting with a Django site that has both a main folder and a static media folder. I'm trying to install django-bootstrap, but not sure how to go about it.

I'm using the instructions in this Django Bootstrap page.

First, do I run

pip install -e git+git://github.com/earle/django-bootstrap.git#egg=bootstrap

from the terminal in the main folder, or static media folder?

Second, where do I insert the usage code?

from bootstrap.forms import BootstrapForm, Fieldset

class LoginForm(BootstrapForm):
    class Meta:
        layout = (
            Fieldset("Please Login", "username", "password", ),
        )

    username = forms.CharField(max_length=100)
    password = forms.CharField(widget=forms.PasswordInput(), max_length=100)

The above is obviously only for login fields, but will I need to include that import language in many files, or just one main one?

EDIT for clarity: My host is WebFaction, which uses a Domain + Webapp = Website structure for site hosting. One of their recommended methods for Django installs is to set up the main Django site in one webapp, and a static media folder in another: see here for details.

I am not the site creator or installer, but have copied the site over into a test version so I can mess with its design while the programmer is unavailable for an extended period. I'm looking into Django Bootstrap as a way to make it easier to redesign the site. My skills are obviously limited, but I'm willing to read/learn!

like image 986
JeanSibelius Avatar asked Mar 29 '12 10:03

JeanSibelius


2 Answers

Django-bootstrap is a Django "app", installed as a python package. Since webfaction doesn't do virtualenv, you should be ok* to just ssh in and run

pip install -e git+git://github.com/earle/django-bootstrap.git#egg=bootstrap

from wherever. This will install django-bootstrap to your global python site-packages folder.

Next, you'll need to make sure django knows about it, which you do by editing the settings file and adding it to INSTALLED_APPS, e.g.

INSTALLED_APPS = (
# ... other things
'bootstrap',
# ... maybe more things
)

Any python file that uses the BootstrapForm and Fieldset classes, will require the import statement at the top of it. A python module (file) will only know about a) what you declare directly in it, and b) what you explicitly import. I don't know how you got anywhere using python without knowing that, because it's pretty important. Consider reading up on the subject.*

Anyhow, the only thing django-bootstrap seems to do is change django's form-rendering code to output HTML that is more compatible with Bootstrap. You will still need get twitter-bootstrap yourself, and make sure that you use the media, i.e. the css, js and images, from it. Put the bootstrap media in your static app.

http://twitter.github.com/bootstrap/

*Edit: I just read the last bit of your post and now I feel like a big meanie. So, here are some extra resources that I recommend you read through.

Python samples: http://wiki.python.org/moin/SimplePrograms

Django's Tutorial: https://docs.djangoproject.com/en/1.3/intro/tutorial01/

like image 172
Adam Bard Avatar answered Nov 19 '22 22:11

Adam Bard


I'm afraid I don't quite understand the question. pip install will install this in de site-packages folder, not in the location you are running the command from.

The code is a form so would go into a forms.py within the app you are trying to make. That form inherits from BootstraForm, so you would just use the LoginForm where you want and it would be a BootstrapForm.

like image 2
nopogo Avatar answered Nov 19 '22 21:11

nopogo