Django: Difference between revisions
Initial page |
Add section about development shell |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It provides built-in components for handling common web-development tasks—such as ORM, templating, authentication, and administration—so developers can focus on writing reusable, maintainable applications. | |||
== Development shell == | |||
This example <code>flake.nix</code> can be used for Django web app development on NixOS<syntaxhighlight lang="nix"> | |||
{ | |||
inputs = { | |||
nixpkgs.url = "nixpkgs/nixos-25.05"; | |||
# Required for multi platform support | |||
flake-utils.url = "github:numtide/flake-utils"; | |||
}; | |||
outputs = { self, nixpkgs, flake-utils }: | |||
flake-utils.lib.eachDefaultSystem (system: | |||
let | |||
pkgs = import nixpkgs { inherit system; }; | |||
start = | |||
pkgs.writeShellScriptBin "start" '' | |||
set -e | |||
${pkgs.python3}/bin/python manage.py makemigrations | |||
${pkgs.python3}/bin/python manage.py migrate | |||
${pkgs.python3}/bin/python manage.py runserver | |||
''; | |||
in | |||
{ | |||
devShell = pkgs.mkShell { | |||
packages = with pkgs; with python3Packages; [ | |||
python | |||
django | |||
requests | |||
beautifulsoup4 | |||
]; | |||
}; | |||
packages = { inherit start; }; | |||
defaultPackage = start; | |||
}); | |||
} | |||
</syntaxhighlight>Adapt the dependencies in the devShell packages part according to your project needs. Run the web app with<syntaxhighlight lang="bash"> | |||
nix develop | |||
nix run | |||
</syntaxhighlight> | |||
== Packaging == | == Packaging == | ||
First we create the package derivation for the Django web app, in this example for Froide-Govplan<syntaxhighlight lang="nix"> | First we create the package derivation for the Django web app, in this example for [[Govplan|Froide-Govplan]]<syntaxhighlight lang="nix"> | ||
{ | { | ||
lib, | lib, | ||
Line 289: | Line 333: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Python]] |