flask/flask-docs/tutorial/database.html
2025-04-11 03:04:22 +00:00

134 lines
7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tutorial &#8212; Flask Documentation (3.2.x)</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
<link rel="stylesheet" type="text/css" href="../_static/flask.css?v=b87c8d14" />
<script src="../_static/documentation_options.js?v=56528222"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script data-project="flask" data-version="3.2.x" src="../_static/describe_version.js?v=fa7f30d0"></script>
<link rel="icon" href="../_static/shortcut-icon.png"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Project Layout" href="layout.html" />
<link rel="prev" title="Quickstart" href="../quickstart.html" />
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="layout.html" title="Project Layout"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../quickstart.html" title="Quickstart"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Flask Documentation (3.2.x)</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Tutorial</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="tutorial">
<h1>Tutorial<a class="headerlink" href="#tutorial" title="Link to this heading"></a></h1>
<div class="toctree-wrapper compound">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="layout.html">Project Layout</a></li>
<li class="toctree-l1"><a class="reference internal" href="factory.html">Application Setup</a></li>
<li class="toctree-l1"><a class="reference internal" href="database.html">Define and Access the Database</a></li>
<li class="toctree-l1"><a class="reference internal" href="views.html">Blueprints and Views</a></li>
<li class="toctree-l1"><a class="reference internal" href="templates.html">Templates</a></li>
<li class="toctree-l1"><a class="reference internal" href="static.html">Static Files</a></li>
<li class="toctree-l1"><a class="reference internal" href="blog.html">Blog Blueprint</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Make the Project Installable</a></li>
<li class="toctree-l1"><a class="reference internal" href="tests.html">Test Coverage</a></li>
<li class="toctree-l1"><a class="reference internal" href="deploy.html">Deploy to Production</a></li>
<li class="toctree-l1"><a class="reference internal" href="next.html">Keep Developing!</a></li>
</ul>
</div>
<p>This tutorial will walk you through creating a basic blog application
called Flaskr. Users will be able to register, log in, create posts,
and edit or delete their own posts. You will be able to package and
install the application on other computers.</p>
<img alt="screenshot of index page" class="screenshot align-center" src="../_images/flaskr_index.png" />
<p>Its assumed that youre already familiar with Python. The <a class="reference external" href="https://docs.python.org/3/tutorial/">official
tutorial</a> in the Python docs is a great way to learn or review first.</p>
<p>While its designed to give a good starting point, the tutorial doesnt
cover all of Flasks features. Check out the <a class="reference internal" href="../quickstart.html"><span class="doc">Quickstart</span></a> for an
overview of what Flask can do, then dive into the docs to find out more.
The tutorial only uses whats provided by Flask and Python. In another
project, you might decide to use <a class="reference internal" href="../extensions.html"><span class="doc">Extensions</span></a> or other libraries
to make some tasks simpler.</p>
<img alt="screenshot of login page" class="screenshot align-center" src="../_images/flaskr_login.png" />
<p>Flask is flexible. It doesnt require you to use any particular project
or code layout. However, when first starting, its helpful to use a more
structured approach. This means that the tutorial will require a bit of
boilerplate up front, but its done to avoid many common pitfalls that
new developers encounter, and it creates a project thats easy to expand
on. Once you become more comfortable with Flask, you can step out of
this structure and take full advantage of Flasks flexibility.</p>
<img alt="screenshot of edit page" class="screenshot align-center" src="../_images/flaskr_edit.png" />
<p><a class="reference external" href="https://github.com/pallets/flask/tree/main/examples/tutorial">The tutorial project is available as an example in the Flask
repository</a>, if you want to compare your project
with the final product as you follow the tutorial.</p>
<p>Continue to <a class="reference internal" href="layout.html"><span class="doc">Project Layout</span></a>.</p>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<span id="sidebar-top"></span>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/flask-vertical.png" alt="Logo of Flask"/>
</a></p>
<h3>Navigation</h3>
<ul>
<li><a href="../index.html">Overview</a>
<ul>
<li>Previous: <a href="../quickstart.html" title="previous chapter">Quickstart</a>
<li>Next: <a href="layout.html" title="next chapter">Project Layout</a>
</ul>
</li>
</ul>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script><div id="ethical-ad-placement"></div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2010 Pallets.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
</div>
</body>
</html>