I am using the standard Admin Panel in Django that has a Model, Product, that contains its information. the Product has a TextField() Summary of words.
I would like to implement a Keyword model that has a single word. The idea is that the Keyword would be applied to multiple Products if the Product has the Keyword's word in its Summary.
I am trying to implement that when the Admin in the Admin panel adds a Keyword model, the server would automatically assign each Product that Keyword.
The issue is that I do not know how to edit the Admin Panel's add function to edit other models upon adding one model. My current understanding in Django is that you could create a custom view to add a Keyword, but I would like to have the option to implement it in the Django Admin Panel as well. Products should have multiple Keywords.
Here is my models.py:
from django.db import models
class Product(models.Model):
id = models.BigAutoField(primary_key=True)
product_summary = models.TextField() # Contains a paragraph of words describing the product
class Keyword(models.Model):
# Used for searching Products by unique keywords to display, like tags.
keyword = models.CharField(max_length=100)
I think you can use the save() function and extend them in your model to do what you want. but this isn't really good for performance since you want to query other objects.
Another way would be to use django signals to signal the other objects.