mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 19:42:37 +02:00
102 lines
No EOL
5.4 KiB
HTML
102 lines
No EOL
5.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<title>
|
|
django - Alexis Métaireau </title>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet"
|
|
href="https://blog.notmyidea.org/theme/css/main.css?v2"
|
|
type="text/css" />
|
|
<link href="https://blog.notmyidea.org/feeds/all.atom.xml"
|
|
type="application/atom+xml"
|
|
rel="alternate"
|
|
title="Alexis Métaireau ATOM Feed" />
|
|
</head>
|
|
<body>
|
|
<div id="content">
|
|
<section id="links">
|
|
<ul>
|
|
<li>
|
|
<a class="main" href="/">Alexis Métaireau</a>
|
|
</li>
|
|
<li>
|
|
<a class=""
|
|
href="https://blog.notmyidea.org/journal/index.html">Journal</a>
|
|
</li>
|
|
<li>
|
|
<a class=""
|
|
href="https://blog.notmyidea.org/code/">Code, etc.</a>
|
|
</li>
|
|
<li>
|
|
<a class=""
|
|
href="https://blog.notmyidea.org/weeknotes/">Notes hebdo</a>
|
|
</li>
|
|
<li>
|
|
<a class=""
|
|
href="https://blog.notmyidea.org/lectures/">Lectures</a>
|
|
</li>
|
|
<li>
|
|
<a class=""
|
|
href="https://blog.notmyidea.org/projets.html">Projets</a>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<h1>
|
|
Tag « django » </h1>
|
|
<section class="section index">
|
|
<time datetime="2024-02-22T00:00:00+01:00">22 février 2024</time> <a class='tag' href="https://blog.notmyidea.org/tag/django.html">django</a>
|
|
, <a class='tag' href="https://blog.notmyidea.org/tag/orm.html">orm</a>
|
|
, <a class='tag' href="https://blog.notmyidea.org/tag/migrations.html">migrations</a>
|
|
<h1>
|
|
<a href="https://blog.notmyidea.org/changing-the-primary-key-of-a-model-in-django.html" id="page-title">Changing the primary key of a model in Django</a>
|
|
</h1>
|
|
<p>I had to change the primary key of a django model, and I wanted to create a
|
|
migration for this.</p>
|
|
<p>The previous model was using django <a href="https://
|
|
docs.djangoproject.com/en/5.0/topics/db/models/#automatic-primary-key-fields">automatic primary key fields</a></p>
|
|
<p>I firstly changed the model to include the new <code>uuid</code> field, and added the <code>id</code>
|
|
field (the old primary key …</p>
|
|
</section>
|
|
<section class="section index">
|
|
<time datetime="2024-02-22T00:00:00+01:00">22 février 2024</time> <a class='tag' href="https://blog.notmyidea.org/tag/django.html">django</a>
|
|
, <a class='tag' href="https://blog.notmyidea.org/tag/urls.html">urls</a>
|
|
, <a class='tag' href="https://blog.notmyidea.org/tag/uuid.html">uuid</a>
|
|
<h1>
|
|
<a href="https://blog.notmyidea.org/using-uuids-in-urls-in-a-django-app.html" id="page-title">Using uuids in URLs in a Django app</a>
|
|
</h1>
|
|
<p>After adding a regexp for uuids (which are quite hard to regexp for), I
|
|
discovered that Django <a href="https://docs.djangoproject.com/
|
|
en/5.0/topics/http/urls/#path-converters">offers path converters</a>, making this a piece of cake.</p>
|
|
<p>I was using old school <code>re_path</code> paths in my <code>urls.py</code>, but it’s possible to
|
|
replace them with <code>path</code>, like this:</p>
|
|
<div class="highlight"><pre><span></span><code><span class="n">url_patterns</span> <span class="o">=</span> <span class="p">(</span>
|
|
<span class="n">path …</span></code></pre></div>
|
|
</section>
|
|
<section class="section index">
|
|
<time datetime="2023-08-16T00:00:00+02:00">16 août 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/django.html">django</a>
|
|
, <a class='tag' href="https://blog.notmyidea.org/tag/pytest.html">pytest</a>
|
|
<h1>
|
|
<a href="https://blog.notmyidea.org/profiling-and-speeding-up-django-and-pytest.html" id="page-title">Profiling and speeding up Django and Pytest</a>
|
|
</h1>
|
|
|
|
<p><a href="https://yaal.coop/">Éloi</a> made <a href="https://github.com/spiral-project/ihatemoney/issues/1214">a pull request on
|
|
IHateMoney</a> to
|
|
speedup the tests, with some great tooling for pytest that I wasn’t aware of:</p>
|
|
<ul>
|
|
<li><a href="https://pypi.org/project/pytest-xdist/">pytest-xdist</a> allows to run tests in
|
|
parallel, using <code>-n auto</code></li>
|
|
<li><a href="https://pypi.org/project/pytest-profiling/">pytest-profiling</a> makes it easy
|
|
to get the call stack and time the function calls that take most …</li></ul>
|
|
</section>
|
|
<ul>
|
|
</ul>
|
|
</section>
|
|
<footer>
|
|
<a id="feed" href="/feeds/all.atom.xml">
|
|
<img alt="RSS Logo" src="/theme/rss.svg" />
|
|
</a>
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
</html> |