İçeriğe geç
KURUMSAL Kurumsal teknoloji · İşletmenize özel mühendislik Kurumsal Yazılım · Yönetilen Sunucular · Kurumsal E-posta · LiteSpeed + CloudLinux · Imunify360 Güvenlik · cPanel Yönetim · Uygun pakette 3 Gbps'ye kadar ağ profili
AIOR

PyCharm IDE'sine Django Çatısı Nasıl Kurulur — Adım Adım Rehber

  • Konu başlatıcısı Konu başlatıcısı Aior
  • Başlangıç tarihi Başlangıç tarihi

Aior

Administrator

Yetkili üye
Katıldı
2 Nis 2023
Mesajlar
929
Tepki puanı
2
Puan
18
Yaş
41
Konum
Turkey
Web sitesi
aior.com
Konu sahibi

Django Nedir, Neden PyCharm?​

Django, Python ile yazılmış olgun, "batteries-included" bir web framework'üdür. Admin paneli, ORM, authentication, migration sistemi, template engine, form yönetimi gibi web uygulaması için gereken her şeyi içerir. PyCharm (JetBrains tarafından geliştirilen Python IDE), Django ile en iyi entegrasyona sahip ortamdır: otomatik tamamlama, debug, migration yardımcıları, template engine syntax desteği.

Bu rehber yeni başlayanlar için PyCharm'a Django kurulumunu sıfırdan anlatır. AIOR olarak Python tabanlı projeler geliştirirken PyCharm Professional sürümünü tercih ediyoruz.

Ön Gereksinimler​

- Python 3.10+ kurulu olmalı (python --version ile doğrulayın)
- PyCharm Community veya Professional sürümü kurulu olmalı (Community ücretsiz ama Django tooling sınırlı; Professional 30 günlük deneme veya öğrenci lisansı ile alınabilir)
- Komut satırına erişim

Adım 1 — Virtual Environment Oluşturma​

PyCharm'da File → New Project menüsünden yeni bir proje oluşturun. "Pure Python" şablonunu seçin. "Python Interpreter" bölümünde New environment using Virtualenv seçili olduğundan emin olun; bu izole bir Python ortamı oluşturur ve global sistem kütüphaneleriyle çakışmayı engeller.

Lokasyon: /Users/me/Projects/django-app gibi anlamlı bir yol seçin. PyCharm otomatik olarak .venv klasörünü oluşturur.

Adım 2 — Django Kurulumu (Terminal İçinde)​

PyCharm'da Terminal sekmesini açın (View → Tool Windows → Terminal). Virtual env aktif olmalı — promptun başında (.venv) görmelisiniz. Django'yu pip ile kurun:

Kod:
pip install django

En son LTS sürümünü kurar. Spesifik bir sürüm gerekiyorsa:

Kod:
pip install django==4.2

Doğrulama:

Kod:
django-admin --version

Adım 3 — Django Projesi Oluşturma​

Aynı terminalde:

Kod:
django-admin startproject mysite .

Sondaki nokta projeyi mevcut dizinde oluşturur (alt dizin yaratmaz). Üretilen dosyalar:

manage.py — Django CLI komutları
mysite/settings.py — yapılandırma
mysite/urls.py — URL routing
mysite/wsgi.py — production deployment

Adım 4 — Geliştirme Sunucusunu Çalıştırma​

Yine terminalde:

Kod:
python manage.py runserver

Çıktıda Starting development server at http://127.0.0.1:8000/ gördüğünüzde tarayıcıdan ziyaret edin. Django'nun "The install worked successfully!" sayfası karşınıza çıkmalı.

Adım 5 — İlk App Oluşturma​

Django projeleri "app" denilen modüllerden oluşur:

Kod:
python manage.py startapp blog

blog dizini oluşur, içinde models.py, views.py, admin.py, apps.py dosyaları yer alır. Bu app'i mysite/settings.py içindeki INSTALLED_APPS listesine eklemeyi unutmayın:

Kod:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',  # ← yeni eklenen
]

Adım 6 — Migration Sistemi​

Django'nun database migration sistemi şemayı kod üzerinden yönetir:

Kod:
python manage.py migrate

Bu komut Django'nun yerleşik tabloları (auth, admin, sessions) için SQL çalıştırır. Yeni model eklediğinizde:

Kod:
python manage.py makemigrations
python manage.py migrate

Adım 7 — Admin Paneli ve Superuser​

Kod:
python manage.py createsuperuser

Username, e-mail, şifre soracaktır. Sonra http://127.0.0.1:8000/admin/ adresinden Django'nun otomatik admin paneline giriş yapabilirsiniz.

PyCharm Spesifik Avantajlar​

PyCharm Professional'da Django desteği şu özellikleri sağlar:
- Template syntax highlighting: {% if %} {% endfor %} {{ variable }} otomatik renklenir
- URL completion: reverse() ve {% url %} tag'ında URL ismi otomatik tamamlanır
- Model field types: CharField, IntegerField gibi alanların tipleri IDE tarafından bilinir
- Manage.py task runner: makemigrations, runserver gibi komutları GUI butonlarla çalıştırın

Üretim Hazırlığı​

Geliştirme tamamlandığında PostgreSQL'e geçiş, DEBUG=False, ALLOWED_HOSTS doldurma ve collectstatic gibi adımlar gereklidir. AIOR hosting paketlerimizde Django uygulamaları için PostgreSQL, Redis ve nginx + gunicorn ön-konfigüre olarak gelir; deployment süreciniz dakikalara iner.


What Is Django, Why PyCharm?​

Django is a mature, "batteries-included" Python web framework. It ships with everything a web app needs: admin panel, ORM, authentication, migration system, template engine, form handling. PyCharm (JetBrains' Python IDE) has the best Django integration available: auto-completion, debugging, migration helpers, template syntax support.

This guide takes a beginner through installing Django in PyCharm from scratch. At AIOR we use PyCharm Professional for our Python-based projects.

Prerequisites​

- Python 3.10+ installed (verify with python --version)
- PyCharm Community or Professional installed (Community is free but Django tooling is limited; Professional offers a 30-day trial or student licensing)
- Command-line access

Step 1 — Create a Virtual Environment​

In PyCharm choose File → New Project. Pick the "Pure Python" template. Under "Python Interpreter", confirm New environment using Virtualenv is selected — this creates an isolated Python environment so global packages don't conflict with your project.

Location: choose a meaningful path like /Users/me/Projects/django-app. PyCharm creates the .venv folder automatically.

Step 2 — Install Django (in the Terminal)​

Open the Terminal tab in PyCharm (View → Tool Windows → Terminal). The virtual env should be active — the prompt should show (.venv). Install Django with pip:

Kod:
pip install django

This installs the latest LTS. To pin a specific version:

Kod:
pip install django==4.2

Verify:

Kod:
django-admin --version

Step 3 — Create the Django Project​

In the same terminal:

Kod:
django-admin startproject mysite .

The trailing dot creates the project in the current directory (no extra subfolder). Files generated:

manage.py — Django CLI commands
mysite/settings.py — configuration
mysite/urls.py — URL routing
mysite/wsgi.py — production deployment

Step 4 — Run the Development Server​

In the terminal:

Kod:
python manage.py runserver

When you see Starting development server at http://127.0.0.1:8000/, open it in your browser. Django's "The install worked successfully!" page should appear.

Step 5 — Create Your First App​

Django projects are composed of "apps" (modules):

Kod:
python manage.py startapp blog

A blog directory appears with models.py, views.py, admin.py, apps.py. Don't forget to add the app to INSTALLED_APPS in mysite/settings.py:

Kod:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',  # ← newly added
]

Step 6 — The Migration System​

Django's migration system manages schema through code:

Kod:
python manage.py migrate

This runs the SQL for Django's built-in tables (auth, admin, sessions). When you add a new model:

Kod:
python manage.py makemigrations
python manage.py migrate

Step 7 — Admin Panel and Superuser​

Kod:
python manage.py createsuperuser

It asks for username, email and password. Then visit http://127.0.0.1:8000/admin/ to log into Django's auto-generated admin panel.

PyCharm-Specific Advantages​

PyCharm Professional's Django support gives you:
- Template syntax highlighting: {% if %} {% endfor %} {{ variable }} colour automatically
- URL completion: reverse() and {% url %} tag get URL name auto-completion
- Model field types: the IDE understands CharField, IntegerField etc.
- Manage.py task runner: run makemigrations, runserver etc. via GUI buttons

Preparing for Production​

Beyond development you'll need PostgreSQL, DEBUG=False, populated ALLOWED_HOSTS and a collectstatic step. AIOR hosting packages ship pre-configured PostgreSQL, Redis and nginx + gunicorn for Django apps — your deployment drops from hours to minutes.
 

Forum istatistikleri

Konular
925
Mesajlar
932
Üyeler
26
En son üye
Jessicawatson

Çevrimiçi üyeler

Şu anda çevrimiçi üye yok.

Öne çıkan içerik

AIOR
AIOR TEKNOLOJİ

Tüm ihtiyaçlarınız için Teklif alın

Hosting · Domain · Sunucu · Tasarım · Yazılım · Mühendislik · Sektörel Çözümler

Teklif al

7/24 Destek · Anında yanıt

Geri
Üst