The Django Pluggables site seems like an awesome list of comparison between different apps/plugins.
http://djangoplugables.com/grids/g/perms/
Tuesday, November 23, 2010
ContentTypes
The ContentTypes framework seems promising as a way to enable apps as instances.
Hm: Note also, that if you delete an object that has a GenericRelation, any objects which have a GenericForeignKey pointing at it will be deleted as well. In the example above, this means that if a Bookmark object were deleted, any TaggedItem objects pointing at it would be deleted at the same time.
Hm: Note also, that if you delete an object that has a GenericRelation, any objects which have a GenericForeignKey pointing at it will be deleted as well. In the example above, this means that if a Bookmark object were deleted, any TaggedItem objects pointing at it would be deleted at the same time.
Could not import settings error Django
I got the following error when I wanted to run my new django app:
Error: Could not import settings 'blog.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings This turned out to be caused by creating an 'app' that has the same name as your 'project'. Renaming my project to 'blogz' solved this issue.
Prefilling the database w/ yaml
Install pyyaml
sudo pip install pyyaml
To save the database in yaml format:
./manage.py dumpdata --format=yaml
or to automatically load the next time the database is synched:
./manage.py dumpdata --format=yaml > fixtures/initial_data.yaml
After all, I prefer the default json format.
./manage.py dumpdata -n --indent=2 > fixtures/initial_data.json
Wednesday, November 17, 2010
Sass and Haml with Django
After working with shpaml, I'd also like to have a better way of writing css.
Easy.
sudo apt-get install ruby libhaml-ruby
I also tried using HAML, but I prefer shpaml. Compare:
%h1 {{ object.question }} {% if error_message %} %p %strong {{ error_message }} {% endif %} %form{:action => "/polls/{{ object.id }}/vote/", :method => "post"} {% csrf_token %} {% for choice in object.choice_set.all %} %input{:id => "choice{{ forloop.counter }}", :name => "choice", :type => "radio", :value => "{{ choice.id }}"}/ %label{:for => "choice{{ forloop.counter }}"} {{ choice.choice }} %br/ {% endfor %} %input{:type => "submit", :value => "Vote"}/ | h1 | {{ object.question }} {% if error_message %} p strong | {{ error_message }} {% endif %} form action="/polls/{{ object.id }}/vote/" method="post" {% csrf_token %} {% for choice in object.choice_set.all %} > input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" label for="choice{{ forloop.counter }}" | {{ choice.choice }} > br {% endfor %} > input type="submit" value="Vote" |
Also, sass has the nifty --watch option, which automatically updates your css files when necessary. HAML does not have this feature currently. Shpaml does not need this; it is automatically run when necessary.
shpaml - haml for python and django
I've searched around for a nicer way to write HTML in Django, somewhat like HAML for Ruby.
... and it works like a charm :)
There is an enormous amount of half-baked packages out there, but I find shpaml to fit my needs wonderfully.
It can be downloaded from
To automatically reload the shpaml templates, run
All together
#download shpaml
wget http://shpaml.webfactional.com/shpaml_py -O shpaml.py
#download django-shpaml-template-loader
python ./django-shpaml-template-loader/setup.py install
rm -rf ./django-shpaml-template-loader
I put the following in my settings file:
#I put the following
#I put the following
TEMPLATE_LOADERS = (
'shpaml_loader.filesystem',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
if DEBUG:
TEMPLATE_LOADERS = (
('django.template.loaders.cached.Loader', TEMPLATE_LOADERS),
)
... and it works like a charm :)
Tuesday, November 16, 2010
Drupal and OpenAtrium
For the last few weeks, I've been researching online collaboration platforms: Drupal and Open Atrium.
Off course, there is another module that takes care of that: features. And features allow you even to install a module into OpenAtrium. Now, not so fast. You also need to understand spaces, strongarm and half a dozen other modules.
I do not understand why people want to work with those. Bending my head around dozens of different modules is a crime. For drupal, you need to understand Views and CCK (the content creation kit). Clicking something together sounds nice, but the whole thing is impossible to put into version control.
Off course, there is another module that takes care of that: features. And features allow you even to install a module into OpenAtrium. Now, not so fast. You also need to understand spaces, strongarm and half a dozen other modules.
Each of these modules sounds great, but comes with another complicated configuration screen with dozens of options - each of which may or may not be the one that you need. Documentation is scattered, bugs are common.
Now, I can follow someone's tutorial with a few dozen steps. But actually creating something new myself? Sadly, after three weeks, I still deem it impossible.
After almost three weeks, I still have not build my own custom content types for an Open Atrium site. It's just too damn hard. It might work for the people who bulit it (developmentseed), but I think the complexity of understanding someone else's framework is too high.
Don't even get me started on PHP. I am praying to be able to change to python/django.
Subscribe to:
Posts (Atom)