In VIM there is a command for char search:
f. After first use it can be repeated with
;. I like to navigate in line with it. You see that you need to go to bracket in a middle of a line - you press
f( and one-two
; and you are there. There's no such command in Emacs, so I had to write my own. I've managed even to implement repetition with
(setq last-search-forward-char nil) (defun search-forward-char-continue () (interactive) (if (and last-search-forward-char (or (eq (symbol-function last-command) (symbol-function 'search-forward-char)) (eq last-command this-command))) (search-forward-char last-search-forward-char) (progn (insert ";") (setq last-search-forward-char nil)))) (global-set-key (kbd "M-s") 'search-forward-char) (global-set-key (kbd ";") 'search-forward-char-continue)
Key word here is
last-command. Using the same principle other commands also can be assigned to same key.
Django ORM is a very abstract and flexible API. But if you do not know exactly how it works, you will likely end up with slow and heavy views, if you have not already. So, this article provides practical solutions to N+1 and high loading time issues. For clarity, I will create a simple view that demonstrates common ORM query problems and shows frequently used practices.
There was a task to submit form with ajax, with server side validation of course. Obvious solution is to do validation and return json with erros. I didn't like idea of writing separate view for validation and then inserting errors in form html on client side. Especially since I already had a generic template for django form with errors display. In this article I'll describe how I solved the task.