Issue with importing apps in Python / Django
Question: I am having an issue while importing 'registration' app into any of my python
scripts (PyCharm showing an error - "Unresolved reference 'registration'").
`Django-registration-redux` has been installed and loads fine e.g. from
`urls.py`. I also have an issue with my own apps, which I never had an issue
with. In the following `urls.py` `user_profile` is also not recognized. How do
you go a folder level up rather than down, I know that if you are going into
folders you include a dot for every folder, **but how do you go back?** This
is probably not relevant for this case but in general. This is my project
layout:

    
    
    |--'project'
    |   |--'Lib'
    |   |   |--'site-packages'
    |   |   |   |--'registration'
    |   |--'src'
    |   |   |--'proj'
    |   |   |   |-- settings.py
    |   |   |   |-- urls.py
    |   |   |--'user_profile'
    |   |   |   |-- forms.py
    

**urls.py**

    
    
    from django.conf import settings
    from django.conf.urls import url, include
    from django.conf.urls.static import static
    from django.contrib import admin
    import user_profile.views as views
    
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        url(r'^$', views.home),
        url(r'^accounts/', include('registration.backends.default.urls')),
    ]
    

**forms.py**

    
    
    from registration.forms import RegistrationFormUniqueEmail
    from django import forms
    
    class UserProfileRegistrationForm(RegistrationFormUniqueEmail):
        field = forms.CharField()
    

**settings.py**

    
    
        import os
    
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    
            INS
    
    TALLED_APPS = [
            'django.contrib.admin',
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',  # manually added
            'django.contrib.messages',
            'django.contrib.staticfiles',
            # third party apps
            'crispy_forms',
            'debug_toolbar',
            # my apps
            'user_profile',
            'registration',
        ]
    


Answer: You don't "go back", because you're not "in" anywhere to go back from.

Python uses the PYTHONPATH environment variable to determine where to import
things from. A virtualenv will automatically put its root and the site-
packages directory into that variable. If your virtualenv is the "project"
directory, you probably need to do `from src.user_profile import views`.

