Version number comparison and beta

16 views
Skip to first unread message

Kevin Golding

unread,
May 1, 2014, 2:36:32 AM5/1/14
to django...@googlegroups.com
Hi all
I'm trying to update some existing code so that it will be compatible with 1.7, in particular the use of settings.AUTH_USER_MODEL instead of get_user_model().
Given the differences I'm going to have to check the version numbers and then have two alternatives eg:

if StrictVersion(get_version()) >= StrictVersion('1.7'):
new code
else:
old code

However the current version number for 1.7 is 1.7b3, which is treated as being less than 1.7 according to StrictVersion.
In order to get it to work the way I want right now I'm going to have to compare with a version number such as 1.7a1,
but this is going to look pretty ugly going forward.

What is the best practice for doing version number comparisons taking into account the existence of beta version numbers?

Thanks
Kevin

Xavier Ordoquy

unread,
May 1, 2014, 3:00:41 AM5/1/14
to django...@googlegroups.com
Hi Kevin,

Le 1 mai 2014 à 08:36, Kevin Golding <kevingol...@gmail.com> a écrit :

What is the best practice for doing version number comparisons taking into account the existence of beta version numbers?

What I’m doing with Django is:

    django.VERSION <= (1, 7)

I can’t remember where I saw this but this worked well for me.

Regards,
Xavier Ordoquy,
Linovia.
Reply all
Reply to author
Forward
0 new messages