Looking for examples of OSS Django projects as PyPi packages

Hi folks,

I know Django does not do this by default, and I know that by default if you find a package with django- in its name on PyPi, the chances are that it is a django app.

Are there any examples you might point me to of full django projects on Pypi, that are packaged up as django packages?

My example, as I figure out how I should be doing this

I’m working on one at the link below, where I have an existing software library, and then a bundled directory containing a minimal django project to use the library in API requests. I’m using granian as a bundled web server for a more suitable alternative to the django web server if this needs to be run in production example.

Why use Django like this?

I’m mainly doing this because if I want to expose an HTTP API on a project, I’m more comfortable with Django than other tools like FastAPI and the rest, and I find the ecosystem of supporting packages very helpful in the Django ecosystem.

Projects like NanoDjango also make me feel a bit better about packaging up Django like this for relatively small projects, because it give some idea of what smaller, or even single-file django projects can look like.

The other reason is that if you’re using uv now, running a Django app could be as simple as calling

uv tool run carbon-txt serve

And if you have it behind a reverse proxy server like Nginx or Caddy, you could theoretically run it in production with something like this invocation (assuming you have a .env file in the same directory):

uv tool run carbon-txt serve --production --server granian

You can see the docs as I’m writing it out. I’ve also written before about using Caddy with Django in this forum, as I think it offers one of the best developer experiences of setting up what can otherwise be quite fiddly.

However, I know that Django has a grain, and I haven’t seen many django projects packaged up onto PyPi to learn from, so I can see what the common patterns are.

So as I said higher up in this post - if you know of any django projects on PyPi, would you share a few links to them?

Ta

As an aside: for those curious about what the above project is about, there’s a fairly in-depth report now online about our plans for carbon.txt, and also a page on the Green Web Foundation website with more info.

1 Like

I never did this @mrchrisadams but in theory you’d package up and define an entry point, as for any cli tool.

Flit is lightweight, and my favourite tool for packaging for pure Python packages.

https://flit.pypa.io/en/stable/pyproject_toml.html#pyproject-project-entrypoints

If you get stuck, I can try a demo for you when I’m at the computer.

1 Like

Thanks @cartongibson!

You can see how I’ve done this here now in that package - here’s the relevant part of the pyproject. I’m calling cli:app to use the typer CLI below:

Within the CLI, there’s a serve command like so:

This turned out to be quite similar to how nanodjango worked - when I looked it up: that has serve command too, but they bundle in Uvicorn, from memory.

I hadn’t got round to deliberately choosing a tool for helping me publish packages yet - so far I had been using a combo of uv build, and then publishing with twine, with uv run twine upload --repository pypi dist/*.

Flit looks nice though - I’ll give it a go.

1 Like

Great! Nice work. :1st_place_medal:

Didn’t know it did that; any Python build tool will do. :+1:

I know at least these: Fiduswriter, Pretalx and Pretix. There are probably more.

1 Like