On Mon, Jun 14, 2010 at 1:59 PM, geraldcor <gregco...@gmail.com> wrote:
> Hello all, > > I have a model A that has >4000 records in it. I have just created a > new model B that has a foreign key to A. I want to be able to create > an instance of B and save it which is no problem going the normal > routes. However, I like to use Ajax to make the load times faster > because a lot of our clients are on slow connections in China. With > the foreign key <option> field being populated by 4000+ values, the > load time for the page is quite slow. I would like to leave > ModelChoiceField off my form and then populate it in my view (or a > hidden input in my form). However, whenever I just try to save the pk > number value into the foreign key, I get the error "Cannot assign > "u'1783'": "MainNode.customers" must be a "Customers" instance." > > How can I just save a number to the foreign key field? Thanks for any > advice and help. > > Greg > If you're talking about this problem in Admin, look at: http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields If it's your own form, you could do something similar. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.