Coder Social home page Coder Social logo

Comments (2)

MaybeThisIsRu avatar MaybeThisIsRu commented on July 3, 2024

I'm going to try this and report back:

One is to subclass the built-in form and view classes of django-registration and make the necessary adjustments to achieve compatibility with your user model. For example, if you want to use the two-step activation workflow, but your user model uses a completely different way of marking accounts active/inactive (compared to the the assumed is_active field), you might write subclasses of that workflow’s RegistrationView and ActivationView which make use of your user model’s mechanism for marking accounts active/inactive, and then use those views along with an appropriate subclass of RegistrationForm.

https://django-registration.readthedocs.io/en/3.1.2/custom-user.html#incompatible-user-models

from django-registration.

MaybeThisIsRu avatar MaybeThisIsRu commented on July 3, 2024

I've overridden the get_form method and removed the check. Note that you must have defined a class property form_class for this to work.

You may choose to implement SOME sort of check rather than no checks at all. For example, by using the __bases__ property to check if your custom user class exists somewhere: form_class._meta.model.__bases__.

I'm no expert here, of course, but this is where I've started:

def get_form(self, form_class=None):
        """
        django-registration checks to see if our custom user model matches the configured user model (from project settings). This doesn't work for our use-case since we have proxy user classes that we want to use. We are overriding this method to skip the check altogether. BE CAREFUL.
        """
        if form_class is None:
            form_class = self.get_form_class()
        return form_class(**self.get_form_kwargs())

Once again, please consider having some sort of check.

from django-registration.

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.