Hello everyone. I've been spending some time with django and I must
admit I find it very intuitive. Hat off to the devs.

What I'm trying to do is write a small survey app. It has these three
basic models:

-----------------------------------------------------------------------------------------------------
class Survey(models.Model):
    name = models.CharField(maxlength=100, unique=True)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.name

    class Admin:
        pass


class Question(models.Model):
    survey = models.ForeignKey(Survey)
    question = models.CharField(maxlength=300)

    def __str__(self):
        return self.question

    class Admin:
        pass

class Choice(models.Model):
    question = models.ForeignKey(Question, edit_inline=models.STACKED,
num_in_admin=4)
    choice = models.CharField(maxlength=200, core=True)
    votes = models.IntegerField(core=True, default=0)

    def __str__(self):
        return self.choice
-----------------------------------------------------------------------------------------------------

I get confused when it comes to updating the models. This is my use
case: A view with the id of the survey should output a page with all
questions related to that survey and all choices related to the
particular question. The choices should be represented by radio buttons
(to get the multiple choice functionality). When the user submits the
form, only the votes should be incremented. Another view would just do
the same thing -- this time just show the votes for each answer.

I think I need to use a custom manipulator, but I get confused about
the way the updating works (especially with a backwards one-to-many
relationship). Am I understanding this correctly? I couldn't find any
examples of this kind of case. 

Any ideas/pointers?


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to