urls.py:
urlpatterns = [
path("",views.index,name = "index"),
path("signup/",views.signup,name = "signup"),
path("login/",views.login,name = "login"),
]
urlpatterns+=static(settings.MEDIA_URL, document_root =settings.MEDIA_ROOT )
settings.py:
STATIC_URL = 'static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
forms.py:
class SignUp(forms.Form):
is_doctor = forms.BooleanField(label = "Are you a doctor?",required=False)
f_name = forms.CharField(label = "First Name", max_length=200)
l_name = forms.CharField(label="Last Name",max_length=200)
username = forms.CharField(label = "Username",max_length = 100)
email = forms.CharField(label = "Email",max_length=200)
profile_pic = forms.FileField(label= "Profile Picture", widget = forms.ClearableFileInput(attrs={'class':'form-control'}),required=False)
password = forms.CharField(label ="Password",max_length=200)
confirm_password = forms.CharField(label = "Confirm Password",max_length=200)
address = forms.CharField(label="Address",max_length = 400)
views.py:
form = SignUp(response.POST,response.FILES)
In the html file I have the attribute: enctype=”multipart/form-data”
I cannot understaNd what else I need to do. I have read so many docs and watched so many videos. They’re all saying the same thing.
New contributor
Pratyush Panda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.