0

I keep getting an error saying that my BundleForm has no attribute is_valid. I double and triple checked and my BundleForm is associated with a model, specifically my Bundle model. I can't figure out why else I would be getting this error. Any comments/input greatly welcomed!

models.py

class Bundle(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
user_profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
name = models.CharField(max_length=100)

def __str__(self):
    return self.name

forms.py

class BundleForm(forms.ModelForm):
    name = forms.CharField(
        help_text='Enter mission name. Change to hidden unless mouse over. ',
        initial='bundle_name',
        required=True,
        max_length=50,
    )

    class Meta:
        model = Bundle             
        fields = ('name',)  

views.py

def new_bundle(request):
form1 = BundleForm()
if request.method == 'POST':
    form1 = BundleForm(request.POST)
    if form1.is_vaild():
        bundle = form1.save(commit=True)
        return render(request, 'build_a_bundle/new_bundle.html', {'bundle':bundle})
    else:
        return HttpResponse('Form 1 Error')    
return render(request, 'build_a_bundle/new_bundle.html', {'form1':form1})
1
  • I literally just had this same typo =|. Commented Jun 21, 2017 at 22:02

2 Answers 2

4

There's a syntax error, change if form1.is_vaild(): to : if form1.is_valid():.

Sign up to request clarification or add additional context in comments.

2 Comments

Ahh, you are my hero =]
@iHeartKayk No problem, has no attribute ... errors are often are related to syntax :)
1

This is a syntax error. I've made the same mistake too.

.is_vaild()

.is_valid()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.