Skip to content

Related Names Fix #10

@Alkandari-Y

Description

@Alkandari-Y

Ingredient model does not have a related_name for the user field.

Recipe model does not provide a related name that correctly represents that relationship.

Remember, related names are used for the reverse relationships, i.e. for the model being referenced in the Foreign Key Field. Meaning, that on line 24 of recipes.models, it should be recipes instead of categories; so that the reverse query for a category instance can easily get all the recipes it has a relation with and make sense.

Currently, to access all the recipes under a category would look like this:

category = Category.get(id=1)
related_recipes_for_category = category.categories.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions