iamvatsalay
iamvatsalay

Reputation: 106

getting module not found error after deploying flask app to heroku server

so i had this flask app running successfully on my Heroku server. i just added contact form functionality to my flask app and everything was working fine on my local machine but after deploying the app on heroku, it's giving me errors. I've checked the heroku logs and the error's looks like this:

from forms import ContactForm
ModuleNotFoundError: No module named 'forms'

app.py (just the importing part)

from flask import Flask, render_template, request, flash
from flask_mail import Mail, Message
from forms import ContactForm

forms.py

from flask_wtf import FlaskForm
from wtforms import TextAreaField, SubmitField, TextField
from wtforms import ValidationError, validators

class ContactForm(FlaskForm):
    name = TextField("Name", [validators.Required("Please enter your fullname")], render_kw={"placeholder" : "Fullname"})
    email = TextField("Email", [validators.Required("Please enter your email adrress"), validators.Email()], render_kw={"placeholder" : "Emaill"})
    subject = TextField("Message", [validators.Required("Enter your subject")], render_kw={"placeholder" : "Subject"})
    message = TextAreaField("Message", [validators.Required("Enter your message")], render_kw={"placeholder" : "Message "})
    send_message = SubmitField("Send")

My folder structure

enter image description here

Procfile

web: gunicorn app.app:app

Upvotes: 1

Views: 244

Answers (1)

iamvatsalay
iamvatsalay

Reputation: 106

ok so now i've figured it out. I just changed the folder structure to something like this:

Project structure

folder structure

Hope it will help others in future.

Upvotes: 1

Related Questions