'function' object has no attribute 'as_view'

IngredientCreateView should be a class. So your views.py replace:

def IngredientCreateView(CreateView):

with:

class IngredientCreateView(CreateView):

In my case, the problem was that I tried to use a @decorator on the class-based view as if it was a function-based view, instead of @decorating the class correctly.

EDIT: From the linked page, here is a way to apply @login_required to a class-based view:

from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator

@method_decorator(login_required, name='dispatch')
class ProtectedView(TemplateView):