Skip to main content


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-\"") I've reinstalled package without success. Reason of this is related to the incorrect doc file version for emacs (emacs is but doc file has .2 at the end)
Fix is really simple :
cd /usr/share/emacs/24.1.50/etc ln -s DOC- DOC- debian:/usr/share/emacs/24.1.50/etc# ls -la DOC* lrwxrwxrwx 1 root root 13 чер 5 17:25 DOC- -> DOC- 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( 'initial', None)