Posts tagged tips

Mac OS X: ⌘ + ⇥ and Dock stops working

If your Dock stops responding (e.g. cannot click application icon) and you can’t switch between applications using ⌘ + ⇥ (Command + Tab) there is an easy way to deal with it without restart.

Just open Activity Monitor (typically ⌘ + ␣), find Dock process and kill process using “Quit Process” option. Dock should be restared after a second and everything should back to normal.

Thursday, May 6, 2010   ()

Django: how to mark required form field with *?

If you want to mark required fields with * or some other text/symbol - don’t use some hacks in your python code (Label modify in form class, etc.). Things like that should reside in templates and all you need to do is to apply this:

{% if field.field.required %} <em>*</em>{% endif %}

E.g. form display template:

<form action="." method="post">
{% csrf_token %}
{% for hidden in form.hidden_fields %}
	{{ hidden }}
{% endfor %}

<dl>
{% for field in form.visible_fields %}
	{% if field.errors %}
		<dt>&nbsp;</dt>
		<dd>{{ field.errors }}</dd>
	{% endif %}
	<dt>
		{{ field.label_tag }}
		{% if field.field.required %} <em>*</em>{% endif %}:
	</dt>
	<dd>{{ field|safe }}</dd>
{% endfor %}
<dt>&nbsp;</dt>
<dd><input type="submit" value="Submit" /></dd>
</dl>
</form>
Wednesday, April 28, 2010   ()