May 2013
2 posts
9 tags
displaying many to many fields in django with...
Das Problem:
You have a field with 246 items to chose from … and you’re asking your users to scroll through them, hold control down, scroll to the next one, ups, forgot the control, start again … grrr. Not pretty.
Do not fret. crispy-forms and chosen.js have come to the rescue. Here’s how it works and how simple it is:
1. Check out a chosen example to see how multi...
4 tags
April 2013
4 posts
1 tag
I don't need to test that. What can possibly go...
devopsreactions:
Image by IceMan1988
12 tags
Reduce your PostgreSQL/PostGIS query time by 99%
In our search engine for renewables, we are running a bunch of PostGIS queries, e.g. to determine the wind speed at a user’s location. In our alpha search engine, we noticed that the PostGIS requests caused the longest query time of all 25 queries.
While experimenting with PostGIS, we discovered a nice time saver: In the alpha version, we translated the CSV data of measurement points (lat,...
7 tags
Handy Git tips to stop you getting fired →
Very nice summary of handy and life-saving git tipps!
March 2013
8 posts
6 tags
patch from file using git diff
Say you want to send a friend a patch, or perhaps you often apply a change back and forth (say like preparing a file for production, and getting it back to testing). In our case base.html uses less.js to render the CSS during development, but in production it calls instead a minified CSS. So to convert base.html between the production and dev versions we created a patch. This is how you do it:
1....
12 tags
git workflow -- emergency fix or how to stash
You’re plowing away in your feature branch in the zone, you’ve messed with 10 files and it still doesn’t work. However you think that in four hours your creation will spring to life.
All of a sudden, you get 20 emails with 500 error reports from production. aaagh! You need to fix that, Quickly!!
$ git checkout master
Not so fast! If you do that, the 10 files you touched will move with you to...
15 tags
14 tags
git workflow -- part 3
Ok, so here’s the third part of our series on our git-workflow (see part-1, part-2). We are 3 or 4 people working with git on a django project. So, what happens when one (and just one) of us needs to develope a small feature independently? This could be an extra form, an additional login option, a new field in the model.py or something that one person can tackle in 1 to 3 days.
Update the local...
15 tags
git workflow - part 2
Before creating a branch, doing a quick fix or messing with the models, we need to make sure our database is the same as the production one.
To do so we have a single bash (or fab) script which does:
This can all be summarized in a fab command which takes into account different OS (linux, mac), different absolute directories, and different naming of files (see fabfile.py in gist)
Ok, so we...
20 tags
git workflow - part 1
This will be a series of exploratory articles on how to do django development in a team of 3 using git. Suggestions from the readers are more than welcome, but the solutions have to be cheap and fast as we’re a bootstraped startup.
Setting the stage:
www.example.com (production)
prod_db backed up automatically and regularly to dropbox and to a git repository with a cron job.
media files,...
5 tags
Interesting Django Error Messages: 'function'...
Django’s debug error messages are usually helpful and provide a good level of description. However, sometimes we encounter error messages, which “amaze” us. We would like to take the chance to summarise the results of our solutions here on this blog.
Today, we worked on a new online feature for re.nooble’s customers. While writing some classes in the particular `views.py`...
4 tags
Transferring Django Flatpages from the local...
At the moment, we are creating a few flatpages for our re.nooble site. Obviously, they are created on a testing/development machine and need to be transferred to the production environment before the release of the latest code feature.
The few lines below will manage the transfer easily.
February 2013
7 posts
Create an API for your django models
http://www.nerdydork.com/basic-authentication-on-mod_wsgi.html
In our case we simply added
WSGIPassAuthorization On
to httpd.conf
20 tags
font-awesome, twitter-bootstrap facepalm moment...
Ok, so I have some django projects using the now ubiquitous twitter bootstrap, together with the fantastish Font-Awesome. No problem. And I like my css LESS flavoured, because … well, because who likes to write css rules over and over? So this results in a folder structure for the assets which looks something like this:
├── assets
│ ├── bootstrap
│ │ ├── docs
│ │ ├── img
│ │ ...
Complex regexp worked exactly as expected
devopsreactions:
Submitted by Leprosy
Perpetual To-Do List
facuberte:
Don’t ignore your dreams
Don’t work too much
Say what you think
Cultivate friendships
Be happy
By Paul Graham
http://paulgraham.com/todo.html
12 tags
django, mysql and ubuntu
Here’s the setup from 0 to 127.0.0.1:8000 in 30 seconds:
I assume you already have python (below version 3.0) in your machine. You also have virtualenv (you can apt-get install python-virtualenv ) and pip.
After that it’s the usual: create some models, runserver and syncdb
2 tags
5 tags
silly django tutorial
from Django’s tutorial,
Because the URL patterns are regular expressions, there really is no limit on what you can do with them. And there’s no need to add URL cruft such as .php – unless you have a sick sense of humor, in which case you can do something like this:
(r'^polls/latest\.php$','polls.views.index')
But, don’t do that. It’s silly.
ha,ha,ha … I’m gonna have...
December 2012
1 post
5 tags
ipdb python debugging, from Greg Aker
November 2012
2 posts
5 tags
pull single commit to another branch
I created the prelaunch branch (a very simplified version of the website to launch on the 21st).
I made a few changes on prelaunch, pushed a few commits and deployed.
In parallel, Hannes added some bug fixes (email, pagination) … but they were only on the master branch. To solve this problems I wanted to pull from master only the specific files and changes that Hannes did (but not all...
3 tags
October 2012
4 posts
How to change a git commit comment?
Simply execute
» git commit —amend -m “New commit message”
Found here - Thank you Stackoverflow.
11 tags
deploying on webfaction to a mysite.com/directory
Something on our host was driving me crazy for hours yesterday.
after deploying to mysite.com/directory, when I followed a link (say about-us) it would take me to mysite.com/about-us instead of mysite.com/directory/about-us.
I thought it might be related to the Site settings and even tried the shell:
>>> from django.contrib.sites.models import Site
>>>...
3 tags
4 tags
robots.txt for a django project on webfaction
Maybe you’re testing your site, maybe you want to leave it in the Deep Web …
in any case if you want to display a “radioactive!!, do not index” sign for search engines you need a robots.txt file at the root of your directory.
So if your site is mysecretsite.com, you want it to be at
mysecretsite.com/robots.txt
To ban all access simply copy paste this in your...
August 2012
5 posts
8 tags
Double Slider - JQRangeSlider and ScrollTo
Inspired by Queness’ article and using Guillaume Gautreau’s nice JQRangeSlider I set out to combine both. You can click on the image to see the demo:
Calling the range slider is actually very easy.
<div class="slider" id="BudgetSlider"></div> ... <script> $("#BudgetSlider").rangeSlider({ bounds: {min: 10, max:10000}, step: 100, defaultValues: {min: 300,...
5 tags
7 tags
Markdown for github and trello
We use trello from Fog Creek Software to organize our coding, writing and business plans. We also use github for sharing code and development.
Both use markdown (trello in the description of a card, github in the README.md files).
Here’s a nice Cheat Sheet [PDF] I just found for the tags and tricks.
8 tags
test post for markup
I’m testing https://github.com/blairvanderhoof/gist-embed
June 2012
2 posts
5 tags
setting up ssh for git on bitbucket →
10 tags
Ubuntu Pangolin 12.04, python, django and urandom
hI just upgraded Ubuntu to version 12.04 and found this error when firing a Django project:
Error: Can’t find the file ‘settings.py’ in the directory containing ‘./manage.py’. It appears you’ve customized things. You’ll have to run django-admin.py, passing it your settings module. (If the file settings.py does indeed exist, it’s causing an...
May 2012
3 posts
5 tags
6 tags
Q: I have a team of scientists readying articles for our custom Django CMS with...
– reply was off topic … but I love Stack Overflow … :)
http://stackoverflow.com/questions/4819984/django-how-to-best-implement-unit-conversion-a-la-markdown
12 tags
Heading South
These are some wind turbines powering an Antarctic Research Station. And that’s also about as South as you can get in your quest for renewable energy. But today we’re writing about migrating your databases South! Or the following scenario:
You create an übercool insightful Django model. You put some data on it, make some templates, … looks good! And then you realize it...
April 2012
5 posts
6 tags
Installing vtiger on webfaction for CRM
Vtiger is an open source CRM (Customer Relationship Management) platform. Its purpose is to let you keep track of contacts, customers, mailing lists, as well as purchase orders, sales leads, create invoices, and a long etcetera. One of its strengths lies in the abundance of extensions and plugins to make it talk to various technologies (Outlook, Firefox, Mobile, etc).
Webfaction is a hosting...
10 tags
7 tags
our friendly chats lately
alvaro: dude, .bash_profile adding, > export PYTHONPATH="/home/username/webapps/app_production/lib/python2.7/:$PYTHONPATH"
hannes: I already have this in my bash_profile. What about tail -f error_django_app.log
alvaro: hum, 2.24.223.4 - - [13/Apr/2012:10:49:37 +0200] "GET / HTTP/1.0" 500 538 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0" and the error [Fri Apr 13 10:49:41 2012] [error] [client 127.0.0.1] os.environ['DJANGO_SETTINGS_MODULE'] = 'someapp.settings' activate_this
hannes: have you had this error? 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
[Fri Apr 13 11: 27:56 2012] [error] [client 127.0.0.1] GeoIPException: Could not find the GeoIP library (tried "GeoIP"). Try setting GEOIP_LIBRARY_PATH in your settings.
alvaro: man, it's late
hannes: ok. good night.
alvaro: good night.
12 tags
backup your Django models in a json file
Perhaps you need to migrate from your local machine to a server, or ship some flatpages to your mate on the other side of the world. Here’s how
$ python manage.py dumpdata flatpages --indent=2 > ma_backup.json
To recover it somewhere else simply do:
$ python manage.py loaddata ma_backup.json
8 tags
/ CTRL-G
– Firefox shortcut to visit a link without the mouse. click the ’ or / key (start typing on the quick find link, hit Enter to follow the link). If you want to move to the next link matching your string use Control-G.
March 2012
9 posts
6 tags
grep -l “some_string” a-directory/*.html
– finds all htlm files in “a-directory/” which contain the string “some_string” inside them and outputs the list of files
3 tags
python -c ‘import settings’ :)
5 tags
$ convert some_image_with_white_background.png -resize 20% -transparent...
– Nifty little trick for quick resize and transparency
5 tags
7 tags
How to start and stop your psql
http://nickcharlton.net/post/postgres-on-lion
$ pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log start
$ pg_ctl -D /usr/local/var/postgres/ stop -s -m fast
Sometimes our database wants to be left alone
At Re.nooble, we develop across timezones and platforms. It is a lot of fun, but sometimes tough to control different code versions and databases.
To simplify the code sharing, we use git. Sharing a database is not much harder, since you can run a database online and you connect the django setup with the online server. The introduction from webfaction explains nicely how you can do that.
...