How to subclass django's generic CreateView with initial data?

后端 未结 3 1747
故里飘歌
故里飘歌 2020-12-13 05:11

I\'m trying to create a dialog which uses jquery\'s .load() function to slurp in a rendered django form. The .load function is passed the pk of the \"alert\" object. Also av

3条回答
  •  臣服心动
    2020-12-13 05:39

    (Edited because what you're trying does actually work)

    I ran into the same problem yesterday, but it's working now – I think I was returning an object instead of a dict in get_initial.

    In terms of fixing your problem, I'm a little suspicious of how much you seem to be doing in post() – could you try it with the default (non-overrided) post()?

    You could also use pdb (or print statements) to check the value of self.get_form_kwargs make sure that initial is being set.

提交回复
热议问题