Organizing a Flask Project Beyond Single File

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 36

  • @prettyprinted
    @prettyprinted  4 роки тому +2

    Join my free course on the basics of Flask-SQLAlchemy: prettyprinted.com/flasksql

  • @stephencollins2831
    @stephencollins2831 5 років тому +17

    This is a fantastic video I wish more people made. Getting something to work can be fairly easy, but structuring the project logically comes only with experience. This is going to help a lot of people (including me).

    • @prettyprinted
      @prettyprinted  5 років тому +1

      I'm glad it helps! Thanks for watching.

  • @harshasomisetty
    @harshasomisetty 3 роки тому

    This video is sooo helpful, for anyone who wants to restructure into folders in the future just change .extensions to ..extensions.
    Also for me I had to import the views after I inited the db with the app

  • @rhettsmedia
    @rhettsmedia 4 роки тому +1

    Great job Anthony this is exactly what I was looking for

  • @md.akib5124
    @md.akib5124 5 років тому +1

    anthony i love your teaching. Your code is so clean

  • @prabhashswain1878
    @prabhashswain1878 3 роки тому

    TQ sir ,this is really awesome flask structure to work with.

  • @martintichy3494
    @martintichy3494 5 років тому +2

    Very useful. Just one question -> how to create database from console with create_app and .extensions. Thanks for your for your work and insights

    • @prettyprinted
      @prettyprinted  5 років тому +1

      Check out my video commands. ua-cam.com/video/wyG3BiL-E5c/v-deo.html

  • @lator1941
    @lator1941 Рік тому

    I read on a SO post that one should use the already "initialized" db object to create the db model class. Although I structured my app the same way you did, I didn't have issues with my app. Everything was all good.
    Is it recommended to use your method? And how about extensions that need extra configuration after their "extension.init_app()" call

  • @b87b84
    @b87b84 5 років тому +1

    Great video! Thanks!

  • @admaxcool
    @admaxcool 5 років тому +1

    Hi Anthony,
    How do I setup a project with multiple app and blueprints and setup flask dance for all of them .

    • @prettyprinted
      @prettyprinted  5 років тому

      That's hard to answer, but you should only need instance of Flask-Dance and then you check if they're authorized in the parts of the app you want ot keep protected.

    • @admaxcool
      @admaxcool 5 років тому

      @@prettyprinted Thanks Anthony

  • @drac8854
    @drac8854 4 роки тому +2

    Hi Anthony i have a small question how will i add data to my db in views.py
    I import db from extension
    And did db.session.add()
    And it in giving me an error saying that
    Application not found

    • @prabhashswain1878
      @prabhashswain1878 3 роки тому

      from . extension import db

    • @drac8854
      @drac8854 3 роки тому +1

      @@prabhashswain1878 thanks for answering i figured it out
      Thanks anyway

  • @MohamedAshraf-zs6nv
    @MohamedAshraf-zs6nv 3 роки тому

    I have multiple applications in blueprint structure, but I'm struggling to access this db object inside applications and use it to create tables.
    I want to create model.py file for each application separately

  • @panzorax.
    @panzorax. 3 роки тому

    hi bro! i want to selected file path or selected folder how can i do ?? (Without save file)

  • @VeronicaSantos
    @VeronicaSantos 4 роки тому

    Basic question (but I am a newer user): what is blueprint?

    • @camnooten110
      @camnooten110 4 роки тому

      A blueprint allows you to separate your endpoints (or routes) into seperate files.

  • @sainco3036
    @sainco3036 5 років тому

    thanks.

  • @muasx1985
    @muasx1985 3 роки тому

    how to setting port or host in this pattern

  • @footballforfun2054
    @footballforfun2054 3 роки тому

    what is in .env and .flaskenv file?

  • @wilsonreuben5307
    @wilsonreuben5307 5 років тому

    Is your website built with flask?

    • @prettyprinted
      @prettyprinted  5 років тому

      It isn't. For the main site it's just HTML. The part for the courses is hosted by Teachable.

    • @wilsonreuben5307
      @wilsonreuben5307 5 років тому

      @@prettyprinted Can something like that be built with flask, the course part?

    • @prettyprinted
      @prettyprinted  5 років тому

      @@wilsonreuben5307 Yeah definitely. I eventually want to remake the site and I might use Flask.

  • @lawrencekatuva8735
    @lawrencekatuva8735 4 роки тому

    File "C:\Users\User\Desktop\Flask\clean\app_stracture\__init__.py", line 3, in
    from .views import main
    ImportError: attempted relative import with no known parent package

    • @I3orjoyzee
      @I3orjoyzee 4 роки тому

      Hi, did you manage solve this errror?

    • @oumao
      @oumao 4 роки тому

      It should be something like
      from myapp.views import main
      where myapp is the name of the folder containing the __init__.py in your case I guess it is app_stracture
      Avoid at all cost naming folder like "app_stracture" try making it simple like cleanapp, appclean, structureapp etc

  • @kishoreandra
    @kishoreandra 5 років тому

    Hey mate....cool video....but what if I want to use a class of different flask project, how can I import it ??note: they both are in different local disc's say E and F

    • @prettyprinted
      @prettyprinted  5 років тому +1

      You don't want to import from other parts of your computer because once you move you project, it will stop working. Instead either install things as a package or move them into your project.