GithubHelp home page GithubHelp logo

Improperly Configured Exception 'Module "djstripe.forms" does not define a "StripeSubscriptionSignupForm" class' about dj-stripe HOT 11 CLOSED

dj-stripe avatar dj-stripe commented on July 19, 2024
Improperly Configured Exception 'Module "djstripe.forms" does not define a "StripeSubscriptionSignupForm" class'

from dj-stripe.

Comments (11)

pydanny avatar pydanny commented on July 19, 2024

Hi @dollydagr, I'm moving today so my ability to quickly help is curtained.

If it helps, my development with this has only been with PostgreSQL. Maybe try it with that or MySQL?

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

Thanks @pydanny for your quick reply. I am digging into this (but I don't believe it's a DBMS issue).
Good luck with your move! Had so many of those.

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

The exception seems to happen more exactly when djstripe/forms.py fails to import SetPasswordField and PasswordField from allauth.account.forms.

In fact, there is nothing that I can import from allauth.account.forms from djstripe's forms.py (or even my app). However, the method from allauth.account.utils could be imported fine. Right now, just to keep going, I redeclared SetPasswordField and PasswordField (and imported them) from myapp/forms.py (which works).

I know this is not an issue particular to djstripe, but if you have an idea why the classes of allauth.account.forms are inaccessible to the other apps, I'd really appreciate your insight (and remove my dirty fix).

My structure is the following:

my_project:
   |_ my_app
   |_ djstripe
   |_ allauth
         |_ account

Thank you!
dollydagr

from dj-stripe.

pydanny avatar pydanny commented on July 19, 2024

@dollydagr Are you using pip or actually copying the code of djstripe and allauth directly into your project?

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

@pydanny I ended up copying the code of djstripe and allauth into my project.
I actually started by pip when I first had this error. As it was hard to trace, I copied the source codes to get a better handle on things and be able to test assumptions (and workarounds). Should I try posting this (what seems to be an) import issue on stackoverflow instead?

from dj-stripe.

pydanny avatar pydanny commented on July 19, 2024

Admittedly, the test coverage on the project isn't where it needs to be. And since I delivered the project powered by dj-stripe, I haven't had a chance to work on it since.

In any case, including it the way you did is probably the cause of the import errors. If you want to use a development version, I recommend cloning it outside and then bringing it into your development environment via python setup.py develop.

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

Thanks @pydanny for the recommendation. For some reason, even with the development environment setup, I am still getting the same error.

In any case, I wanted to change the signup interaction flow. The current signup form, when filled with both credentials and payment errors, will first and only display stripe errors. When these are fixed, it erases all the payment information to display the credentials (username, password) errors.

So I ended up separating both out. I am making sure my user signs up and verifies their identify. And then I collect their payment. I now integrated all dj-stripe templates into my website, and it's great!

from dj-stripe.

pydanny avatar pydanny commented on July 19, 2024

Hey @dollydagr, what should I do with this ticket? Close it? Put a note in the docs and then close it?

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

Yes @pydanny, this left me perplex, just close it (until/if someone else encounters the issue).

from dj-stripe.

dustinfarris avatar dustinfarris commented on July 19, 2024

I ran into this as well. It looks like it is being caused by what would end up being a circular import

in allauth/account/forms.py (truncated):

def _base_signup_form_class():
    ...
    try:
        fc_class = getattr(mod, fc_classname)
    except AttributeError:
        raise exceptions.ImproperlyConfigured('Module "%s" does not define a'
                                              ' "%s" class' % (fc_module,
                                                               fc_classname))

class BaseSignupForm(_base_signup_form_class()):
    ...

djstripe tests for the presence of allauth with the following:

try:
    from allauth.account.utils import setup_user_email
    from allauth.account.forms import SetPasswordField  # circular import occurs here
    from allauth.account.forms import PasswordField
except ImportError:

When reading allauth.account.forms allauth attempts to import the signup form indicated in settings.py, in this case djstripe.forms.StripeSubscriptionSignupForm which hasn't been defined yet. The only reason this isn't actually causing a circular import error is because allauth is testing for the existence of the class as an attribute of the parent module and raising an exception when it doesn't find it.

from dj-stripe.

dollydagr avatar dollydagr commented on July 19, 2024

Makes sense. Thanks @dustinfarris!

from dj-stripe.

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.