Wednesday, January 15, 2014

Re: Problem with Form with ForeignKey field

Does it have anything to do with the related name of animal being `+`? I can't test this out just yet, but I don't THINK you can have a related_name as just `+`, I believe it needs to be a valid identifier.

On Wednesday, 15 January 2014 03:26:12 UTC+11, Drew Ferguson wrote:
Hi

Django 1.5

I have a model which includes a ForeignKey field defined likes this

class Document(models.Model):
  name = models.CharField(max_length=25, unique=True,
        null=False,blank=False)
  target = models.CharField(max_length=12,
        choices=TARGETS,default='report')
  content = models.TextField(null=False, blank=False)
  fieldlist = models.TextField(null=True, blank=True)
  multitarget = models.BooleanField(default=True, null=False,blank=False)
  template = models.ForeignKey('Template',null=True,blank=True,
        related_name='documents')
  animal = models.ForeignKey('Animal',null=True,blank=True,
        related_name='+')

the Animal table is quite large (>3000 records)

When a form template is called, there are no input fields rendered, just a
"save" button

If the Animal field is suppressed in the form with

    class Meta(object):
        model = Document
        exclude = ['animal',]

the form renders correctly with appropriate input fields

Could someone suggest how to track down what is causing the problem with
the Animal selector when it is being generated? Is there a data issue
perhaps?

Thanks
--
Drew

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ab47e117-9bc8-4277-bba3-0c82ad225940%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate