Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Create a Django Project

In this video, you’ll create a Django project using the django admin command. You can use your terminal window, just as you did in the previous lesson.

Start by running the django admin command with startproject, followed by the name of the project, which in this case is portfolio. If you put a period (.) at the end of the command, then you can avoid creating an extra folder.

Comments & Discussion

tsusadivyago on Dec. 28, 2019

My default port 8000 was being used, so I tried with

python manage.py runserver 8080

reblark on Feb. 18, 2020

Hi Martin, As you know, I completed this course once before. I have completed other courses since but remember this one as the best. So, I am going to run through it again. Already, your detailed commentary helped me solve a problem I was having in another course. That was great and I am looking forward to re-doing this course. Cheers.

Martin Breuss RP Team on Feb. 19, 2020

Hi and welcome back for the second round @reblark. :) Glad it’s been useful, and training your skills by doing exercises over again is definitely a great way to learn. Keep up the motivation!

littleblueline on Feb. 20, 2020

Guys I keep getting the following error as soon as i try to run the server:`` Microsoft Windows [Version 10.0.18362.657] (c) 2019 Microsoft Corporation. All rights reserved. PycharmProjects\Portfolio app>python manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File “H:\Coding\lib\threading.py”, line 926, in _bootstrap_inner self.run() File “H:\Coding\lib\threading.py”, line 870, in run self._target(self._args, self._kwargs) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\utils\autoreload.py”, line 53, in wrapper fn(args, kwargs) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\core\management\commands\runserver.py”, line 109 , in inner_run autoreload.raise_last_exception() File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\utils\autoreload.py”, line 76, in raise_last_exc eption raise _exception[1] File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\core\management__init__.py”, line 357, in execu te autoreload.check_errors(django.setup)() File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\utils\autoreload.py”, line 53, in wrapper fn(*args, kwargs) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django__init__.py”, line 24, in setup apps.populate(settings.INSTALLED_APPS) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\apps\registry.py”, line 114, in populate app_config.import_models() File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\apps\config.py”, line 211, in import_models self.models_module = import_module(models_module_name) File “H:\Coding\lib\importlib__init__.py”, line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “<frozen importlib._bootstrap>”, line 1006, in _gcd_import File “<frozen importlib._bootstrap>”, line 983, in _find_and_load File “<frozen importlib._bootstrap>”, line 967, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 677, in _load_unlocked File “<frozen importlib._bootstrap_external>”, line 728, in exec_module File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\contrib\auth\models.py”, line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\contrib\auth\base_user.py”, line 47, in <module>

class AbstractBaseUser(models.Model):

File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\models\base.py”, line 121, in new new_class.add_to_class(‘_meta’, Options(meta, app_label)) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\models\base.py”, line 325, in add_to_class value.contribute_to_class(cls, name) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\models\options.py”, line 208, in contribute_t o_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db__init__.py”, line 28, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\utils.py”, line 207, in getitem backend = load_backend(db[‘ENGINE’]) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\utils.py”, line 111, in load_backend return import_module(‘%s.base’ % backend_name) File “H:\Coding\lib\importlib__init__.py”, line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “C:\Users\Shaun\PycharmProjects\Portfolio app\venv\lib\site-packages\django\db\backends\sqlite3\base.py”, line 14, in <modul e> from sqlite3 import dbapi2 as Database File “H:\Coding\lib\sqlite3__init__.py”, line 23, in <module> from sqlite3.dbapi2 import * File “H:\Coding\lib\sqlite3\dbapi2.py”, line 27, in <module> from _sqlite3 import * ImportError: DLL load failed: The specified module could not be found.``

And it is driving me absolutely insane.  I have tried installing sqlite3 manually or through pycharm and nothing works.

Martin Breuss RP Team on Feb. 21, 2020

Hi @littleblueline. It often helps to search for the last line of your error message online and look through the answers, e.g. in your case:

from _sqlite3 import * ImportError: DLL load failed: The specified module could not be found.

Reading over it, it seems that your system isn’t finding the database connector (sqlite3 for the default Django setup).

From your traceback I can also see that you’re on Windows. Are you working with the Anaconda Python distribution? I don’t see anything pointing clearly to that in your traceback, but still asking :) If you are, try creating your virtual environment with conda instead. You can read up on the steps for that in Creating development environments and installing Django with Anaconda.

I personally don’t have too much experience working with Python on Windows, and I’ve heard there are sometimes troubles brewing there…

Two ways that often work well for Python on Windows are:

  • Anaconda distribution: It comes pre-installed with a bunch of libraries geared towards data science, so not exactly what you’re looking for when doing web development.
  • Windows Store: You can now download Python 3 through the Windows store, which helps setting some PATH issues right from the start.

You could try those, or drill down some more on what exactly the issue is on your machine by doing some more research with the specifics of your system. E.g. when you include more search terms, such as the error message, “PyCharm”, your windows system and the way you installed Python, as well as how you created the venv etc.

Hope this helps, and let me know your system specifics and what you come up with in your search, and I can bounce back some more updated debugging ideas. :)

littleblueline on Feb. 22, 2020

Thank you for the advice, man. I uninstalled everything Python related on my computer as I had multiple versions, as well as Pycharm. I reinstalled everything today making sure to select the latest versions. It seems to be working fine now!

Martin Breuss RP Team on Feb. 22, 2020

Yay, that’s great to hear :)

Brandy Wright on March 3, 2020

I dont see anyone having mentioned the error I’m getting so I’m adding that here in case someone can offer some insight while I keep working on it:

Django version 3.0.3, using settings 'portfolio.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[03/Mar/2020 13:22:47] "GET / HTTP/1.1" 404 2033
Not Found: /favicon.ico
[03/Mar/2020 13:22:48] "GET /favicon.ico HTTP/1.1" 404 2084

I see online articles for ‘creating a favicon.ico’ but I’m not keen to do that when it wasnt mentioned in this video…

Brandy Wright on March 3, 2020

Solved: Regarding the favicon.ico problem I describe above, I simply deleted the “portfolio” folder and the “manage.py” file from my django-portfolio directory and repeated these steps:

jango-admin startproject portfolio .
python manage.py runserver

Works fine now.

Maybe this will help someone else down the road.

Martin Breuss RP Team on March 5, 2020

Great! I’ve mentioned this in some other comments, but it seems that you downloaded the .zip file and started working with the already finished project. That file is meant only as a reference, for following this course you should build the code from scratch. Which is what you did here, by deleting the folder and re-creating it anew with the appropriate commands :)

Note: (just for the sake of being precise and avoiding confusion for other readers) It has to be:

django-admin startproject portfolio .

The d got lost somewhere on the way to our comment server 😜

Become a Member to join the conversation.