I am attempting to access ForeignKeys in Class Based Views CreateView. I would like to be able to dynamically set initial values in CBV from ForeignKeys and also dynamically
You need to instantiate your recipe:
class IngredientAddView(CreateView): model=Ingredient def get_initial(self): recipe = get_object_or_404(Recipe, slug=self.kwargs.get('slug')) return { 'recipe':recipe, }