It appears that Django Taggit doesn't support transliteratable tags, what we need to do is to add such support, how you may ask? We should use proxy models. Just add this piece of code to, let's say, ru_taggit.py file:

When Solr Thumbnail (https://github.com/mariocesar/sorl-thumbnail) returns and error like "SuspiciousOperation: Attempted access to '/media/products/505.jpg' denied" or Bad request: 400 you need to check the path of the image you want to resize: it shouldn't start with your MEDIA_ROOT like  '/media/products/505.jpg'.

Debugging python code is extremelly simple and powerfull. Just use ipdb for this purposes:

pip install ipdb

Then open up your code and in the place where you need code to stop insert this:

If you have a fieldgroup in a node, you may want to hide it on some conditions. Here's how to do that programmatically.

At first, we need to preprocess our node like this:

Yesterday, during a meeting with my Drupal friends, I showed them some Python magic including Fabric () and how it can be used to make your Drupal dev life easier. My friends been blown away ;) I promised to share my regular fabfile.py for a Drupal project, please see it below, just a note: this is really beginner's code and I'm not responsible for any damages or losses it can bring. Okay, here it is:

When you save your main object and want to attach / create / modify attached to it related models you need to remember the following:

1) Do this in post_save signal, because related objects need pk and you get pk in post_save (when you create a new object)

2) If you manipulate ForeignKey or OneToOneField in post_save(), no additional moves needed. Manipulate there, don't forget to save() objects after the manipulation. For example: main.related.save()

Surprise surprise! When you save a model via admin forms it's not an atomic transaction. The main object gets saved first (to make sure it has a PK), then the M2M is cleared and the new values set to whatever came out of the form. So if you are in the save() of the main object you are in a window of opportunity where the M2M hasn't been updated yet. In fact, if you try to do something to the M2M, the change will get wiped out by the clear().

There are situations, when you or other modules alter username via hook_username_alter() and this can change username dramatically: for example, you can alter username into a combination of First and Last Name, etc.

Django sitetree is a great app to manage your Django app menus. Sometimes, you'll have a page that you want to manually put under a sitetree, so how to do that? At first we need to patch a sitetreeapp.py like this:

To compare two times you need to do the following:

Pages

Subscribe to TimOnWeb RSS