How and where should I put a version number in my Django project?

80 views
Skip to first unread message

Martin Torre Castro

unread,
May 3, 2016, 5:21:38 AM5/3/16
to Django users

I'm making a Django project consisting of several apps and I want to use a version number for the whole project, which would be useful for tracking the status of the project between each time it comes to production.


I've read and googled and I've found how to put a version number for each django app of mine, but not for a whole project.

I assume that the settings.py (in my case it would be base.py, because the settings are inherited for each environment: developmente, pre-production, production) would be the ideal file for storing it, but I would like to know good practices from other Django programmers, because I haven't found any.


Thank you in advance

Mike Dewhirst

unread,
May 3, 2016, 5:36:42 AM5/3/16
to django...@googlegroups.com
On 3/05/2016 7:21 PM, Martin Torre Castro wrote:
> I'm making a Django project consisting of several apps and I want to use
> a version number for the whole project, which would be useful for
> tracking the status of the project between each time it comes to production.
>
>
> I've read and googled and I've found how to put a version number for
> each django app of mine, but not for a whole project.
>
> I assume that the *settings.py* (in my case it would be base.py,
> because the settings are inherited for each environment: developmente,
> pre-production, production) would be the ideal file for storing it, but
> I would like to know good practices from other Django programmers,
> because I haven't found any.

Have a look at Django itself in ../site-packages/django/__init__.py

Mike

>
>
> Thank you in advance
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1487d708-62f4-4ea0-844b-c61107e58746%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1487d708-62f4-4ea0-844b-c61107e58746%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Martín Torre Castro

unread,
May 3, 2016, 5:48:04 AM5/3/16
to django...@googlegroups.com
I will look it at night.

Thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/OrvIGmSW8_4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Nate Granatir

unread,
May 3, 2016, 11:31:54 AM5/3/16
to Django users
You can put the version for your project in:
my_project/my_project/__init__.py (same folder as settings.py)
like this:
__version__ = '1.0.27'

Then your project acts as a python module, and you can refer to the version number, for instance in your settings.py, as:
GRAPPELLI_ADMIN_TITLE = 'My Project v{}'.format(my_project.__version__)

(Here the Grappelli plugin uses this in the headers of all its admin templates.)

Nate

Scot Hacker

unread,
May 3, 2016, 11:38:57 AM5/3/16
to Django users
Another approach is to use git commit IDs and/or git tags to track releases, then display that data (and commit date) in a template, only to superusers or some group. I did a little blog post about this recently:


./s

Reply all
Reply to author
Forward
0 new messages