Tuesday, September 5, 2017

Re: Dynamic model, reverse foreign key not working

On Tue, Sep 05, 2017 at 04:56:10AM -0700, Roman Akopov wrote:
> Unfortulately, it did not help. I have added "model._meta._expire_cache()"
> call almost everywhere, before generating dynamic model, after, between
> steps, it did not help a bit, error is exactly the same.
> Also, I have additionally tested my application against django 1.10 and
> django 1.9 and got exactly the same result.

On which models did you call that? You should call it on the target
model of any relationship that you create dynamically. So if you have
existing models Target1, and Target2, and create a new model Dynamic
with a ForeignKey(Target1) and ManyToManyField(Target2), you'd need to
call _expire_cache() on Target1 and Target2 right after creating the
dynamic model, but before trying to make any queries using those new
reverse relations.

If this doesn't help, then you might have to investigate if there's
perhaps some cached attribute that doesn't get cleared.

Good luck,

Michal

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20170905123820.GL8762%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment