On Thu, Feb 13, 2020 at 6:34 PM Sourish Kundu <[email protected]> wrote:
> So I am trying to access one of my models created in views.py in another > script. This second script is the one I would like manually run. It imports > the model without any errors; however, when I try to run it using PyCharm, > I get this error: > Firstly, what are your models doing in views.py? I am assuming it was a typo. > > *django.core.exceptions.ImproperlyConfigured: Requested setting > INSTALLED_APPS, but settings are not configured. You must either define the > environment variable DJANGO_SETTINGS_MODULE or call settings.configure() > before accessing settings.* > > Any help on resolving this issue would be very much appreciated. > For scripts like these that are not part of your web server or that do not take part in the request-response cycle, I like to implement them as custom Django commands. You can read more about them here <https://docs.djangoproject.com/en/3.0/howto/custom-management-commands>. > > > Thanks, > Sourish > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/2c9b2d34-a9ab-4a2f-a1e4-e2694c265ea0%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/2c9b2d34-a9ab-4a2f-a1e4-e2694c265ea0%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD%3DM5eSBrbLvnFBzoGfOaJk3NnWG8t1N2aOQTmHR6TDsup3F%2BA%40mail.gmail.com.

