I have the following model structure in django.
Category:
- name
- description
Tag:
- name
Article:
- guid
- title
- detail
- tags (Many2Many with Tag)
- cats (Many2Many with Category)
Now, in my main (up to 100,000) task of updating an article, I have to follow these steps.
- for each article:
- to check if this article has already appeared in another category
- if yes, associate article with current category
- if no, create article along current category
- to check if any of associated tags are exists or not,
- if not exists create tag, and associate with current article
- if exists, just associated with current article
During this operation, I already have a dictionary of existing articles that have been extracted from the database.
Since ManyToMany fields do not affect select operations, such as select_related () in django, is there any other way that can help me load existing articles along with categories and tags?
source
share