Coder Social home page Coder Social logo

flask-blog-tutorial's Introduction

Flask-Blog-Tutorial

A blog application in python using Flask.

flask-blog-tutorial's People

Contributors

techwithtim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flask-blog-tutorial's Issues

Delete multiple posts

It is not possible to delete all posts when there are multiple posts created by one user.

no logout.html file in templates folder (tutorial3)

In turtorial3 file, here is no logout.html file in the templates file but there is a reference "href="/logout" in base.html in line 30

I don't know if I am right or completely wrong about this.

If I am wrong, sorry for your waste of time

i am getting an error the for tutorial 1

I am getting the following error when runing the create_function function:

Traceback (most recent call last): File "c:\Users\aalba\OneDrive\Documents\techwithtim_Flask\app.py", line 1, in <module> from website import create_app ImportError: cannot import name 'create_app' from 'website' (c:\Users\aalba\OneDrive\Documents\techwithtim_Flask\website\__init__.py)

I believe it is something silly. The code is exactly the same could it be something with the path variable or venv?

Comments add to existing posts

When you delete a post, create a new one with the same id as the old post, the comments from the old post show up on the new post.

Problem with your SQLite table!

Hi Tim!
The default argument of the column date should be a function, not the function response.
You wrote: "default=func.now()"
But you should write: "default=func.now" (pass the function as an argument…)

Error in Tutorial 2

I am getting this error in tutorial 2 and I am unable to create the database to store the user sign-up info

from flask_sqlalchemy import SQLAlchemy
from .extension import SQLAlchemy
from .model import _QueryProperty
class DefaultMeta(BindMetaMixin, NameMetaMixin, sa.orm.DeclarativeMeta):
AttributeError: module 'sqlalchemy.orm' has no attribute 'DeclarativeMeta'

there should be another base function defined to render base.html

from flask import Blueprint, render_template
from flask_login import login_required, current_user

views = Blueprint("views", name)

@views.route("/")
def base():
return render_template("base.html", name="guest")
@views.route("/home")
def home():
return render_template("home.html", name=current_user.username)

Getting an error while sign up or login, I think its about database problem! please help me!

Hi, I am having an error while running your final tutorial 5 while signing or login in, it looks like it can't create or identify any database! Can you please take a look, at where is the problem? Thanks in advance.

OperationalError
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user
[SQL: SELECT user.id AS user_id, user.email AS user_email, user.username AS user_username, user.password AS user_password, user.date_created AS user_date_created
FROM user
WHERE user.email = ?
LIMIT ? OFFSET ?]
[parameters: ('[email protected]', 1, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Traceback (most recent call last)
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1960, in _exec_single_context
self.dialect.do_execute(
^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute
cursor.execute(statement, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The above exception was the direct cause of the following exception:
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1488, in call
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1466, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 872, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 870, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/flask/app.py", line 855, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/myProjects/testWebApp/website/auth.py", line 38, in sign_up
email_exists = User.query.filter_by(email=email).first()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2727, in first
return self.limit(1)._iter().first() # type: ignore
^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2826, in _iter
result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2306, in execute
return self._execute_internal(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
result = conn.execute(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1408, in execute
return meth(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 513, in _execute_on_connection
return connection._execute_clauseelement(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1630, in _execute_clauseelement
ret = self._execute_context(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1839, in _execute_context
return self._exec_single_context(

File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1979, in _exec_single_context
self._handle_dbapi_exception(
^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2335, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1960, in _exec_single_context
self.dialect.do_execute(
^
File "/Users/arnob_t78/.pyenv/versions/3.11.6/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute
cursor.execute(statement, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user
[SQL: SELECT user.id AS user_id, user.email AS user_email, user.username AS user_username, user.password AS user_password, user.date_created AS user_date_created
FROM user
WHERE user.email = ?
LIMIT ? OFFSET ?]
[parameters: ('[email protected]', 1, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

No home.html file

The home.html file is not updated past video tutorial #1. I tried to view the code in the home.html file for Tutorial #3 but it has the code for Tutorial #1 in all of the versions.

Warning when running.

There is a warning when running and restarting the server.

Warning:

C:\Users\username_that_i_am_not_disclosing\Cloned GIT Stuff\Flask-Blog-Tutorial\venv\lib\site-
packages\flask_sqlalchemy\__init__.py:873: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant 
overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '

after uploading and run on to cpanel am getting below errors

App 2146154 output: /opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 2146154 output: import sys, os, re, imp, threading, signal, traceback, socket, select, struct, logging, errno
App 2146154 output: Traceback (most recent call last):
App 2146154 output: File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in
App 2146154 output: app_module = load_app()
App 2146154 output: File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
App 2146154 output: return imp.load_source('passenger_wsgi', startup_file)
App 2146154 output: File "/home/yutijjfa/virtualenv/public_html/app/webroot/pybot/3.8/lib64/python3.8/imp.py", line 171, in load_source
App 2146154 output: module = _load(spec)
App 2146154 output: File "", line 702, in _load
App 2146154 output: File "", line 671, in _load_unlocked
App 2146154 output: File "", line 783, in exec_module
App 2146154 output: File "", line 219, in _call_with_frames_removed
App 2146154 output: File "/home/yutijjfa/public_html/app/webroot/pybot/passenger_wsgi.py", line 9, in
App 2146154 output: application = wsgi.app
App 2146154 output: AttributeError: module 'wsgi' has no attribute 'app'

ImportError

Hello everyone, i keep getting this issue:

from .models import Post, User
ImportError: attempted relative import with no known parent package
I would appreciate it if anyone could help.

could somebody help me please.

Issue deleting posts

After testing the finished product I have noticed that when you make more than one post the website says that you do not have permission to delete the second post

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.