Friday, June 26, 2015

Re: Model cache problem

I think you've used choices=Apple.objects.all, instead of choices=Apple.objects.all(). With the added parentheses, the 'all()' is evaluated each time the form is loaded. Only using 'all' is once evaluated and then used over and over.

Jarmo

On Thu, Jun 25, 2015 at 9:49 PM Vijay Khemlani <vkhemlan@gmail.com> wrote:
Are you using a ModelChoiceField?


Or a normal ChoiceField setting the choices manually?

On Thu, Jun 25, 2015 at 11:28 AM, dragon <ybdragon@gmail.com> wrote:
Hi!

I have a form with a choice field. I fill it from a model let's name it Apples. And when I delete a row from Apples model the choice field includes the deleted Apple after page reloading. I use this Apple choice form another page and on that page there's the deleted Apple row too. When I choose the deleted row the application throw a DoesNotExist exception (very well). I try it debug mode and when I restart the app it will be ok. The deleted apple row not in the choice filed. And of course the deleted row not in the sql anymore. So the deletion is successfull.

How can I refresh the choice filed, or regenerate the model after row deletion?

dragon

--
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/558C101D.4030905%40gmail.com.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei1PaAdKR3doVkcam%3DRer%3DAcU%3DWk8AiJA0d_gh-nrQt0hw%40mail.gmail.com.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALqR7pTv9rkaEyAHMPAwOvSotrgvTBrDpdtUhnKS2%3DocXjKaXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment