Import error with Python Django
Question: (Note: I have found a workaround, as stated at the bottom, but it seems like
the wrong way to go about this.)

`views.py` and `forms.py` are both in

`R:\\jeffy\\programming\\sandbox\\python\\django_files\\tutorial\\django_test\\django_test\\`

and

`R:\\jeffy\\programming\\sandbox\\python\\django_files\\tutorial\\django_test\\`

is in Django's "Python Path"

But when attempting

    
    
    from forms import MyRegistrationForm
    

in `views.py`, it results in an `ImportError ... No module named 'forms'`.

~~I changed it to

    
    
    from django_test.forms import MyRegistrationForm
    

but that results in `SyntaxError ... invalid syntax`.~~

Since

`R:\jeffy\programming\sandbox\python\django_files\tutorial\django_test\django_test`

is a package (it has the empty `__init__.py` file in it), I thought I could
refer to `django_test` in this way. (It's also the Django project name.)

I can manually add

`R:\\jeffy\\programming\\sandbox\\python\\django_files\\tutorial\\django_test\\django_test\\`

to the `PYTHONPATH` environment variable (Windows 7, 32 bit, Django 1.7c2),
and get it to work. But since this implies that _every_ Django project must be
added to the `PYTHONPATH`, it seems like it should be able to work without
having to do this.

Am I correct? Is there a way to import `forms.py` from `views.py` (which is in
the same directory) without having to manually add its directory to the
`PYTHONPATH`?

Thanks.


Answer: If it's in the same directory, try a relative import:

    
    
    from .forms import MyRegistrationForm
    

_EDIT:_ Someone posted this same suggestion as a comment already. I didn't see
the comment.

