On Sep 23, 7:05 am, "Petar Marić" <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I'm creating a Django based web application for my Master thesis and I've got > a hard problem. This is my model (greatly simplified): > > class Questionnaire(models.Model): > title = models.CharField() > description = models.TextField() > created_by = models.ForeignKey(User, editable=False) > > class Question(models.Model): > title = models.CharField() > questionnaire = models.ForeignKey(Questionnaire) > position = PositionField(unique_for_field='questionnaire') > > class Answer(models.Model): > title = models.CharField() > question = models.ForeignKey(Question) > position = PositionField(unique_for_field='question') > > I'm using theadminapp for creating Questionnaires and I'd like to let users > edit questions and answers in the same form. AFAIKrecursiveinlinesaren't > supported in Django (a hard problem by itself) so the only other way I could > think of is to inject a TextArea form field inside of the QuestionInline and > then do the processing of it manually. Answers would then be separated by > newlines and the positions would be determined by the order of lines in the > TextArea. > > The problem is I don't know how to inject the TextArea in the inline. I tried > many things from simple to complex - and the otherwise excellent documentation > doesn't give much help.
Hi Petar, Like, wow, talk about crazy timing. I'm working on an exam generation app which, being young and naive, thinks it can grow up to cover everything from basic quizzes to questionnaires, surveys and graded tests. It's still about a week or two from a preview release (and much more than that from being really ready) but since I think it's very relevant to your question, I guess I'll have to break security. Oh well, the best laid plans of mice et cetera. The part you'd probably be interested in uses a custom ModelAdmin which displays a sortable list of questions and sub-modules in a test, with an "edit" link for each item, and an "add question" popup menu for the test and for each sub-module. Creating and editing questions and modules is done via this custom admin - there are no Question or Module links in the admin app list - and users never see a "test" field in the question forms. I actually spent some time working on a nested-inline form for this, but realized rather quickly that it wasn't just really hard to write (and even harder to maintain) but will result in a complicated and unfriendly UI. I don't know if you might be more interested in the full app or just the admin code, so let me know if you'd like to see any of it. And, like I said above, code at Google and a demo site are probably a couple of weeks away. Itai --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---