As stated in the title, I keep getting an error when trying to create a form. It's on the line that has:
from collection.forms import contact_form
An I'm getting the error:
File "/home/mike/CINS465/465proj/project/firstapp/views.py", line 2, in <module>
from collection.forms import contact_form
ImportError: No module named 'collection'
Any idea where I'm going wrong? I'm new to django and this was pulled from a tutorial on creating a contact form. I thought collection was built-in to django
Edit:
from views.py
from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from .models import *
from .forms import contact_form
# Create your views here.
def contact(request):
form_class = contact_form
return render(request, 'contact.html', {
'form': form_class,
})
from urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'contact/$',views.contact, name='contact'),
]
from contact.html
{% block title %}Contact - {{ block.super }}{% endblock %}
{% block content %}
<h1>Contact</h1>
<form role="form" action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
from forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth.models import User
class contact_form(forms.Form):
contact_name = forms.CharField(label='Contact Name', max_length=255)
contact_email = forms.CharField(label='Contact Email',max_length=255)
contact_message = forms.CharField(
label='Contact Message',
required=True,
widget=forms.Textarea
)
I didn't include code that was irrelevant (i.e. index page).