Code

Opened 5 years ago

Closed 4 years ago

#12451 closed (invalid)

limit_choices_to with ajax support

Reported by: scorpid Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

class Survey(models.Model):
	name = models.TextField()
	def __unicode__(self):
		return self.name	

class ChoiceGroup(models.Model):
	order = models.IntegerField(max_length=2)
	choice = models.CharField(max_length=60)
	def __unicode__(self):
		return self.choice

class Question(models.Model):
	survey = models.ForeignKey(Survey)
	questionText = models.TextField()
	choices = models.ManyToManyField(ChoiceGroup)
	def __unicode__(self):
		return self.questionText
    
class Answer(models.Model):
	ip = models.CharField(max_length=20)
	question = models.ForeignKey(Question)	
	givenAnswer = models.ForeignKey(ChoiceGroup, limit_choices_to={Question.choices}) '''### i want that given answer can be selectable only 
from question's answers in the admin panel. Is this possible? Or can you make a patch for that? '''
	def __unicode__(self):
		return self.ip

in the admin->answers form when i choose a question it will limit given answers to my chosen question's answer group. This would be a great feature if you can do it by ajax.

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Sure - but that would be outside the scope of the Django core. Django has an explicit policy of not blessing a single javascript toolkit, and keeping itself to a server-side framework. Choosing widgets is a client-side decision.

If you want AJAX widgets for Django, there are plenty of options available. Google is your friend.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.