1

I am learning django from a book. According to instruction I created a forms.py file inside the same directory that views.py exists. Inside the file I wrote the following codes:

from django import forms

class ContactForm(forms.Form):
    subject = forms.CharField()
    email = forms.EmailField(required = False)
    message = forms.CharField()

Then after entering virtual environment through env_mysite\scripts\activate I started python. After than I typed:

from mysite.forms import ContactForm
f = ContactForm()

But I receive the following message after a lot of file paths

django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but 
settings are not configured. You must either define the environment variable 
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
settings.

I opened setting.py file and USE_I18N was True

I have just followed the instruction from tutorial book I but don't understand what is wrong here. Could you please help

reza
  • 31
  • 1
  • 5

1 Answers1

1

It seems like there's nothing wrong with that part of your project (the Form you've created there) or that language code configuration. It looks like you are simply not indicating which Django project to run, in your shell.

Please refer to this answer.

Command: Run this command: python manage.py shell

Through this, you can access your models and form

ATS
  • 31
  • 5
S_alj
  • 447
  • 1
  • 3
  • 15
  • I found the problem. In the command prompt I just entered python typing python. I should have types python manage.py shell – reza Dec 03 '17 at 18:44