def post(self, request, id):
        '''create a bucketlist item'''
        # get the bucketlist object
        bucketlist = get_object_or_404(Bucketlist, pk=id)

        # validate form
        form = CreateBucketlistForm(request.POST)

        if form.is_valid():
            item_name = form.cleaned_data['name']

            # create and save bucketlist item
            item = BucketlistItem(name=item_name, bucketlist=bucketlist)
            item.save()

            # create success message
            messages.add_message(request,
                                 messages.INFO,
                                 'Bucketlist item created')
        else:
            # send back form errors as messages
            for error in form.errors:
                messages.add_message(request,
                                     messages.ERROR,
                                     form.errors[error])
        return HttpResponseRedirect(reverse('frontend:bucketlist_items', kwargs={'id': id}))
    def post(self, request):
        '''creates a bucketlist for a user'''

        # validate form
        form = CreateBucketlistForm(request.POST)

        if form.is_valid():
            bucketlist_name = form.cleaned_data['name']

            # create a new bucketlist
            new_bucketlist = Bucketlist(name=bucketlist_name,
                                        created_by=request.user)
            new_bucketlist.save()

            messages.add_message(request,
                                 messages.INFO,
                                 'Bucketlist successfully created.')
        else:
            # send back form errors as messages
            for error in form.errors:
                messages.add_message(request,
                                     messages.ERROR,
                                     form.errors[error])

        return HttpResponseRedirect(reverse('frontend:dashboard'))