Setting unique=True on a ForeignKey has the same effect as using a OneToOneField


#1

After installing django-registration-redux I get the following warning in console. Being new to Python and Django, I wouldn’t even know where to begin fixing this. Any clues that could set me on the tight path? Thank you.

get WARNINGS:
registration.RegistrationProfile.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.

#2

Sorry for the delayed response, was traveling! You can ignore that message as it’s just a hint. Out of curiosity, are you one of the Kickstarter backers? I actually had it as a ForeignKey in early versions of the book and updated it to OneToOne in the final version, wondering if I have an old version floating out there!


#3

No I wasn’t one of the backers…this is a great book; already at the deploy stage. You did a great job writing this. I realized the error/warning came from using Python3. Once I converted to the same version you used in the book, for the purpose of consistency, I didn’t see the error again.

Thanks for the reply…


#4

Cool, glad it helped! Still weird that your book has ForeignKey as I did a search on the book and all references are OneToOneFields. No judgement here, I don’t care — you didn’t happen to torrent the book or get it from a friend? I’m just concerned I have an old version of the book somewhere, and if you grabbed it from alternate channels, it would explain why yours still has ForeignKey. :)


#5

No torrent here, it was money well spent :)


#6

Yay! Hope you didn’t mind me asking. :) Would you mind letting me know if you bought from Gumroad, Amazon, or Leanpub? :D


#7

It was through Gumroad


#8

Thank you, investigating those files! Thanks for your help. ^_^