Skip to main content

Posts

Showing posts from 2012
My emacs is failed to start after debian update. Debugger entered--Lisp error: (error "Cannot open doc string file \"/usr/share/emacs/24.1.50/etc/DOC-24.1.50.1\"") I've reinstalled package without success. Reason of this is related to the incorrect doc file version for emacs (emacs is 24.1.50.1 but doc file has .2 at the end) Fix is really simple : cd /usr/share/emacs/24.1.50/etc ln -s DOC-24.1.50.2 DOC-24.1.50.1 debian:/usr/share/emacs/24.1.50/etc# ls -la DOC* lrwxrwxrwx 1 root root 13 чер 5 17:25 DOC-24.1.50.1 -> DOC-24.1.50.2   Emacs is OK after this.

Passing values from the view to the form.

Passing values from the view to the form it is really popular. Ex: form should be different for different kind of the user. Unfortunately I have not seen a documentation how to do this with class based view. This task is separated in the two parts: 1) Prepare values in the view class Myview(): """ This is only example view """ # set form form_class = myformwithadditionallogic # our function which pass some values to the form def get_initial(self): """ Passing initial values to the form""" # default initial should be saved super(Myview, self).get_initial() self.initial = {"ourvalue":1} return self.initial That all for view. Second part is retreive this data in the form: class myformwithadditionallogic(): """ the example form . has no field only constructor """ def __init__(self, *args, **kwargs): """ Constructor """ myvalues = kwargs.pop( '