Answer the question
In order to leave comments, you need to log in
Flask doesn't see *.py files?
Freebsd 10.1 python34
test project by structure
/1/
-- run.py
/1/app
----__init__.py
----views.py
----models.py
when starting ./run.py
in views. py on import:
from models import User
stumbles and throws: ImportError: No module named models
But if you move the models.py file to the project root /1/ it works as expected --- what's wrong?
(looked at habrahabr => Flask Mega-Tutorial.)!!!
################################################### #####
/1/run.py
from app import app
if __name__ == '__main__':
app.run
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
from app import views, models
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
from app import app, db
import os, sys
from models import User
@app.route('/')
def index():
return render_template('index.html)
@app.route('/product/')
def product():
return render_template('product.html)
app_dir = os.path.realpath(os.path.dirname(__file__))
database_path = os.path.join(app_dir, app.config['DATABASE_FILE'])
if not os.path.exists(database_path):
db.create_all()
from app import db
class User(db.Model):
id = db.Column(db.Integer,primary_key = True)
username = db.Column(db.String(64), unique = True, nullable=False, index = True)
password = db.Column(db.String(64))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question