Hi everyone. I’m a PHP refugee, brand new to Python/Django, and trying to wrap my head around it.
According to the documentation, I need to:
- install Python
- set up a virtual environment (venv)
- install Django inside that virtual environment.
Am I understanding correctly that there is no global installation of Django? That it only gets installed inside each venv for each project?
Also, do I set up a venv for each project as well?
Thanks in advance for your help.
While you can do a global installation of Django, it’s not typically recommended.
That’s one option, but it’s not your only choice.
There are a couple people here who include their venv within their project directory. Works great for them.
We don’t do it that way. We have a venv that might get used for three or four different projects, when those projects need to remain closely related. We also might have two or three venvs for a single project, if we need to verify functionality in different environments.
Since we do a fair amount of “mix & match”, we can’t tie a project to a single venv.
Beyond the installation, I don’t know how you’re planning to proceed from this point - but I always recommend that people new to Django work their way through either (or both!) of the Official Django Tutorial and the Django Girls Tutorial.
Welcome to Django!
Thanks @KenWhitesell. The official tutorial somehow doesn’t seem clear on some things - probably my old brain’s fault, lol. As a Python/Django beginner, I’m just trying to create a basic website to see how everything works in this world. Static pages, a database, nothing dynamic.
So when does a venv become a necessity or good idea? Without one, is this something I’d want to shoot for?
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
Don’t lose sight that Django is a Python library, not a system in itself. Yes, there are parts of the Django docs that assume some degree of Python proficiency, so if there’s something that seems to be ignored in Django (such as a detailed description of a “virtual environment”), broaden your search to look for Python resources discussing that topic rather than just Django.
First, using a virtual environment is always a good idea. I don’t personally know any serious Python developer recommending against using them.
Whether you want it as another directory within your top-level
[projectname] directory or in a different location is a completely separate issue - and one that doesn’t have “one” correct answer. If you’re only working with Django and not writing other Python code for that same virtual environment, then your decision really doesn’t matter much either way. It really is just an arbitrary choice at this point.
I had done the first installation, and tried first website show “hello world!”, but sounds the code change in setting.py and urls.py had no response. The website always show [The install worked successfully! Congratulations!]http://localhost:8000. Show Django Administration login page if entering http://localhost:8000/admin…
If you’re having a problem with a different code base, please open up a new discussion topic for it.
Sounds my problem is setting problem.
Using the URLconf defined in
, Django tried these URL patterns, in this order:
The current path,
meetups , didn’t match any of these.
You’re seeing this error because you have
DEBUG = True in your Django settings file. Change that to
False , and Django will display a standard 404 page.
Please open up a new topic for this.
Also, do not post screenshots. Copy / paste your code into the body of the message, surrounded by lines of three backtick - ` characters. You’ll have a line of ```, then your code, then another line of ```.