D
D
dstdfx2016-02-28 23:31:03
Django
dstdfx, 2016-02-28 23:31:03

"SystemError: Parent module '' not loaded, cannot perform relative import" what is the error?

article/
...
├── forms.py
├── __init__.py
├── models.py
├── static
│   ├── article
│   └── static_root
├── templates
│   ├── about.html
│   ├── article
│   ├── contact.html
│   └── thanks.html
├── urls.py
└── views.py

forms.py:
from django import forms

class ContactForm(forms.Form):
    subject = forms.CharField(max_length=50)
    message = forms.CharField(widget=forms.Textarea)
    sender = forms.EmailField()
    cc_myself = forms.BooleanField(required=False)

views.py:
...
from .forms import ContactForm
from .models import Article
...

I'm getting a strange error:
Traceback (most recent call last):
  File "/home/danya/PycharmProjects/blog/article/views.py", line 8, in <module>
    from .forms import ContactForm
SystemError: Parent module '' not loaded, cannot perform relative import

What can be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cyber_bober, 2016-02-29
@Cyber_bober

try removing the dot
from forms import ContactForm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question