Monday, March 26, 2018

Re: survey form

i have build an app that allow the admin to add survey title, question and choices. I needed assistance display all the questions and answer in front end to allow the users to take the survey. can i do that with a form. needed  directions.

my models.py

class Survey(models.Model):
    title = models.CharField(max_length = 200,blank=True)
    def __unicode__(self):
        return self.title

class Question(models.Model):
  
    question_text=models.CharField(max_length=100,blank=True)
    Survey_Title = models.ForeignKey(Survey,on_delete=models.CASCADE,default="")
    def __unicode__(self):
        return self.question_text




class answer(models.Model):
 
    question=models.ForeignKey(Question,on_delete=models.CASCADE)
    answer_text=models.CharField(max_length=200,blank=True,default="")
    option=(
                ('Yes','Yes'),
                ('No','No'),

    )
    Selection_an_Option=models.CharField(max_length=100,choices=option,blank=True,default="")
    def __unicode__(self):
        return self.answer_text


class SurveyAnswer(models.Model):
    orig_survey = models.ForeignKey(Survey,on_delete=models.CASCADE)

class QuestionAnswer(models.Model):
    answer = models.ForeignKey(answer,on_delete=models.CASCADE)
    survey_answer = models.ForeignKey(SurveyAnswer,on_delete=models.CASCADE)


Cheers



On Wed, Mar 21, 2018 at 5:02 PM, sum abiut <suabiut@gmail.com> wrote:
Thanks heaps Mike.


On Wed, Mar 21, 2018 at 3:21 PM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
On 21/03/2018 1:17 PM, sum abiut wrote:
Hi,
I am planning to build a survey app that allow the administator to add new questioner and the question to be answer by the users.But i am having trouble figuring how to get started. Just wondering if i need to have two models one for the answes and another model to store the questions. I need some directions.

The official Django tutorial builds a poll app. I could be wrong but that sounds like exactly what you want.

https://docs.djangoproject.com/en/2.0/intro/tutorial01/



cheers
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com <mailto:django-users+unsubscribe@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_ipzrSbBUuaYPGg%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_ipzrSbBUuaYPGg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4vbkj1sXh7YuSJ3%3D2NL%2B_%3DxOvQsmq8yc7WeQOXOrTd9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment