How do I filter data in a ForeignKey Django to display the corresponding data?
class Entrepreneur(models.Model)
f
...
Class Skills(models.Model)
usevalue = models.ForeignKey(Entrepreneur)
rating = (rating = models.PositiveSmallIntegerField(validators=[MinValueValidator(0),MaxValueValidator(5)])
Hello I am on a professional project and I had a question given that I am a young developer for the moment I did not know how to filter the data of the skills model for the entrepreneur and that I can filter it and then I can display it on the frontend. Thank you for your answers.
If you are searching for skills for a specific Entrepreneur using there pk, you you can link tables together easily in Django
skills = Skills.objects.filter(usevalue__id="your entrepreneur id value")
Or if you are searching for an entrepreneur for a specific for a rating of skill
entrepreneurs = Entrepreneur.objects.filter(skills__rating="skill rating value")
Also note you should have an on_delete parameter on your foreign key