title: Import problem in pycharm with django tutorial
body: <p>Yesterday I started learning django with this tutorial:
  <a href="https://www.youtube.com/watch?v=IMG4r03G6g8" rel="nofollow noreferrer">https://www.youtube.com/watch?v=IMG4r03G6g8</a></p>
  <p>But I am getting an <code>Import Error</code> here:</p>
  <p>file: <code>django_1/src/dj30/urls.py</code></p>
  <pre><code>from django.contrib import admin
  from django.urls import path
  
  from posts.views import post_list_view # ERROR LINE
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('posts/', post_list_view)
  ]
  </code></pre>
  <p>This is my directory tree:</p>
  <p><a href="https://i.stack.imgur.com/fQ2LKl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fQ2LKl.png" alt="enter image description here" /></a></p>
  <p>I assume that the <code>Import Error</code> occurs because I am trying to import <code>posts.views.post_list_view</code> from <code>posts/views.py</code> into <code>dj30/urls.py</code> which is in another directory. How does the guy in the tutorial do it? I am positive that I followed the tutorial correctly (I did it twice). Maybe there is a problem with <code>venv</code> because I am using <code>PyCharm</code> (com) and he is not.</p>
  <p>Here are relevant files that were edited during the tutorial:</p>
  <p><code>django/src/dj30/settings.py</code>:</p>
  <pre><code>&quot;&quot;&quot;
  Django settings for dj30 project.
  
  Generated by 'django-admin startproject' using Django 3.1.2.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/3.1/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/3.1/ref/settings/
  &quot;&quot;&quot;
  
  from pathlib import Path
  
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
  BASE_DIR = Path(__file__).resolve().parent.parent
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = 'z=5t$_w+c@k3u+e1c-1tn6xoolrm#*ki*#@kh1u_*=rmwxtk!s'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = []
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'posts'
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'dj30.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'dj30.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': BASE_DIR / 'db.sqlite3',
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/3.1/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.1/howto/static-files/
  
  STATIC_URL = '/static/'
  </code></pre>
  <p><code>django_1/src/dj30/urls.py</code>:</p>
  <pre><code>from django.contrib import admin
  from django.urls import path
  
  from posts.views import post_list_view
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('posts/', post_list_view)
  ]
  </code></pre>
  <p><code>django_1/src/posts/models.py</code>:</p>
  <pre><code>from django.db import models
  
  # Create your models here.
  
  class Post(models.Model):
      title = models.CharField(max_length=120)
      description = models.TextField()
  
      def __str__(self):
          return self.title
  </code></pre>
  <p><code>django_1/src/posts/admin.py</code>:</p>
  <pre><code>from django.contrib import admin
  
  # Register your models here.
  
  from .models import Post
  
  admin.site.register(Post)
  </code></pre>
  <p><code>django_1/src/posts/views.py</code>:</p>
  <pre><code>from django.shortcuts import render
  
  from .models import Post
  
  # Create your views here.
  
  
  def post_list_view(request):
      post_objects = Post.objects.all()
      context = {
          'post_objects': post_objects
      }
  
      return render(request, 'posts/index.html', context)
  </code></pre>
  <p><code>django_1/src/posts/templates/posts/index.html</code>:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;This is the list of all posts.&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>Edit:</strong></p>
  <p>When I try to run <code>urls.py</code> this error occurs:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/Artur/Desktop/django_1/src/dj30/urls.py&quot;, line 4, in &lt;module&gt;
      from posts.views import post_list_view
  ModuleNotFoundError: No module named 'posts'
  </code></pre>
  <p>Running <code>manage.py</code> with <code>runserver</code> produces this website:</p>
  <p><a href="https://i.stack.imgur.com/QouW0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QouW0.png" alt="enter image description here" /></a></p>
  <p>When I comment out:</p>
  <pre><code>from posts.views import post_list_view
  </code></pre>
  <p>and</p>
  <pre><code>path('posts/', post_list_view)
  </code></pre>
  <p>the site is shown correctly:</p>
  <p><a href="https://i.stack.imgur.com/GHH4ul.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GHH4ul.png" alt="enter image description here" /></a></p>
  <p><strong>Edit_2:</strong></p>
  <p>Going to <code>http://127.0.0.1:8000/posts/</code> as suggested shows this:</p>
  <p><a href="https://i.stack.imgur.com/akRAB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/akRAB.png" alt="enter image description here" /></a></p>
  <p><strong>Edit_3:</strong></p>
  <p>Changing <code>urls.py</code> to:</p>
  <pre><code>from django.contrib import admin
  from django.urls import path
  
  from posts.views import post_list_view
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('posts/', post_list_view),
      path('/', post_list_view)
  ]
  </code></pre>
  <p>produces this output:</p>
  <pre><code>C:\Users\Artur\Desktop\django_1\venv\Scripts\python.exe C:/Users/Artur/Desktop/django_1/src/manage.py runserver
  Watching for file changes with StatReloader
  Performing system checks...
  
  System check identified some issues:
  
      WARNINGS:
      ?: (urls.W002) Your URL pattern '/' has a route beginning with a '/'. Remove this slash as it is unnecessary. If this pattern is targeted in an include(), ensure the include() pattern has a trailing '/'.
      
      System check identified 1 issue (0 silenced).
      October 18, 2020 - 09:44:14
      Django version 3.1.2, using settings 'dj30.settings'
      Starting development server at http://127.0.0.1:8000/
      Quit the server with CTRL-BREAK.
  </code></pre>
  <p>and this website:</p>
  <p><a href="https://i.stack.imgur.com/GKySE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GKySE.png" alt="enter image description here" /></a></p>