What's the best way to share Django classes you've written?

I’ve been a developer for about 25 years, and about 2 or 3 years ago, I started seriously learning both Python and Django at the same time for work (mostly for 1 big project). In that time, I have developed a few classes/packages that I modularized as superclasses to be able to be used in any project. Currently, the associated files live with the main project, but I’ve been thinking about packaging them up to be able to share with others, which should be straightforward (functionality-wise). I’ll need to organize some documentation, add a license, etc., and publish it to PyPI, at least as a first step.

But I’m wondering what other avenues might exist, perhaps specifically for Django, where it could be published. Like, should I consider submitting a pull request to the Django codebase? I took a look at the contributing doc, but the feeling I got from reading through that, it seems to be geared toward bug fixes, picking up tickets, and requesting features.

Then I noticed in the package index that there are a series of modules under django.contrib. Contributing a module like that isn’t mentioned in the contributing doc I looked at. I looked at the first (admin) module and then edited the URL (to go up a directory) to discover an overview of contributed modules. And at the bottom, it says:

If you have an idea for functionality to include in contrib, let us know! Code it up, and post it to the django-users mailing list.

Do you have documentation that goes over how to structure and submit such a contribution, or should I just look at one of the existing contributed modules and try to mimmic it?

The feeling I get from having followed the discussions for a few years now is that there’s a desire to see that a package is “successful” and “generally useful” before even being considered for adoption into the Django project itself.

See What is django.contrib? - Jacob Kaplan-Moss for some perspective on this.

Based on that, I’d suggest you package it up, publish it on PyPI and see if it gains traction.

1 Like

OK, yeah, that makes sense. I guess what I was imagining might exist is something like a django-specific collection of searchable and separately-installable optional modules, like a conda “channel”, a galaxy “toolshed”, or a node-red “node library” (of npm packages) that makes django-specific modules easy to find (i.e. not distributed with core django code).

I know that node-red contrib modules specify (or used to specify) a package naming convention (e.g. node-red-contrib-*) and have guidelines for submission that aren’t as exacting as for inclusion in the core codebase.

I take it the django.contrib modules are part of the core codebase and that there’s not a django-specific repository of optional user-contributed modules like that? But I’m also guessing if I publish to pypi, the least I could do is prepend django- to the module name like node-red suggests for npm nodes.

Not a repository, but there is a general “index” site - djangopackages.com - on which you can list your package.

1 Like

Oh, perfect! I think that’s just what I was looking for. Thanks!