Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
Cody, This is a REALLY large list, so I recommend at this level of detailed question to StackOverflow. It is a great resource and lots of Django developers like to show off and write your code for you sometimes :-). Short answers: There are ways to do custom inline forms: http://stackoverflow.

Re: How to use a list in a django model

2013-04-10 Thread Cody Scott
Also if a Question changes and it is used in multiple quizzes all question instances will also need to change. I think I am missing something. Here is my models.py class Product(models.Model): name = models.CharField(max_length=256, unique=True) def __unicode__(self): return

Re: How to use a list in a django model

2013-04-10 Thread Cody Scott
I also want to have the same question in multiple quizzes. But the count for each option should be dependent on the Quiz. I can do the same thing to Quiz in the admin and add Questions Inline but then to add Choices to the Questions I need to go to the question panel and there will be a lot of

Re: How to use a list in a django model

2013-04-10 Thread Cody Scott
Perfect Answer! I must have been sleeping when I did that part of the tutorial. Now I understand it and even learned about actions and this is what my duplicate action looks like def duplicate_questions(modeladmin, request, queryset): for obj in queryset: new_question = Question(ques

Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
You can create and edit choices right in the Question admin view. You can even control how many blank slots to show by default. Go look at ChoiceInline admin here in the tutorial: https://docs.djangoproject.com/en/dev/intro/tutorial02/ The next step would be to create an admin action on Questi

Re: How to use a list in a django model

2013-04-10 Thread Cody Scott
I like the is_correct and the count attributes! The problem with that it is hard to make a quiz in the admin section. You create a quiz and a question but then you have to go to the choice section and create choices for the question. And even if you have the same choice in two questions you nee

Re: How to use a list in a django model

2013-04-10 Thread Brian Schott
Is a many-to-many what you really want? How common are the choices and suppose someone goes in an edits one of the choices and suddenly it doesn't match up right with a different linked question. It might make sense to use a reverse foreign key one-to-many relationship and provide a mechanism

How to use a list in a django model

2013-04-10 Thread Cody Scott
I am trying to store questions in a database. I don't to set a fixed number of options for the question, some questions could have 4 or 2 or 5. Currently I am using a ManyToManyField to a table that just contains a CharField. This works but creating an option requires making another Choice objec