Giter VIP home page Giter VIP logo

Comments (4)

vsemionov avatar vsemionov commented on September 22, 2024

https://stackoverflow.com/questions/45911440/why-does-django-set-a-shorter-maximum-length-of-foreign-keys-to-auth-user-userna

from boomerang.

vsemionov avatar vsemionov commented on September 22, 2024

I think the reason for this behavior is the undocumented swappable property of the User model. It is designed to be replaceable by custom models. However, the configured model must have its data in the initial migration of the app that defines the model. The migrations code seems to generate references to the initial migration of swappable models. I am using the default User model, and its initial migration sets the username to 30 chars. Hence my username FKs are 30 chars long. I am able to work around this with a RunSQL migration to alter the FK data type to varchar(15), but I am in doubt if it's the right thing to do.

from boomerang.

vsemionov avatar vsemionov commented on September 22, 2024

It is left to explain how the populate script worked before. It is possible that it worked at a time when user child objects referred to users by id instead of username and joins were performed to handle user child requests.

from boomerang.

vsemionov avatar vsemionov commented on September 22, 2024

Leaving it as it is for now. Added commit 789d73c with a note about a known bug, a fix for the populator and a potential migration as a workaround that can be applied later.

from boomerang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.