İçeriğe geç
KAMPANYA Kurumsal Web Paketi — $499'dan başlayan fiyatlar Web & Logo Tasarımı · Kurumsal E-posta · LiteSpeed + CloudLinux · Imunify360 Güvenlik · cPanel Yönetim · 3 Gbps DDoS Koruması 00 Gün 00 Saat 00 Dk 00 Sn
AIOR

Creating a Django Project with PyCharm — Configuration From Scratch

Sektör topluluğu — sorularınız, deneyimleriniz ve duyurularınız için.

Creating a Django Project with PyCharm — Configuration From Scratch

  • Thread starter Thread starter Aior
  • Start date Start date
  • Featured

Aior

Administrator
Staff member
Joined
Apr 2, 2023
Messages
895
Reaction score
2
Points
18
Age
40
Location
Turkey
Website
aior.com
1/3
Thread owner

PyCharm Professional ile Django Project Wizard​

PyCharm Professional sürümü Django'ya entegre bir proje oluşturma sihirbazı sunar. Bu sihirbaz virtual environment kurulumundan başlayarak Django paketlerini indirir, ilk proje yapısını oluşturur ve çalışmaya hazır bir geliştirme ortamı sunar. Bu rehber Professional sürümün Django wizard'ını adım adım kullanmayı anlatır.

Yeni Proje Oluşturma​

PyCharm'ı açıp File → New Project menüsünden başlayın. Sol taraftaki proje tipleri listesinde Django'yu seçin. Eğer Django seçeneği yoksa Community sürümü kullanıyorsunuzdur — bu durumda Pure Python seçip elle pip ile Django'yu kurmanız gerekir.

Proje Yapılandırması​

Açılan formda şu alanları doldurun:

Location: /Users/me/Projects/django-app gibi anlamlı bir dizin yolu girin. PyCharm bu yola tüm proje dosyalarını yerleştirir.

Python Interpreter: New environment using Virtualenv seçili olmalı. Base interpreter olarak sisteminizdeki Python 3.10+ sürümünü işaretleyin. Virtual environment proje izolasyonu sağlar; bir projedeki paket sürümleri başka projeyi etkilemez.

Application name: ilk Django app'i için isim verin, örneğin blog veya shop. PyCharm proje yapısını oluştururken bu app'i de hazırlar.

Otomatik Oluşan Yapı​

"Create" butonuna bastıktan sonra PyCharm şu yapıyı oluşturur:

Code:
django-app/
├── .venv/                 # Virtual environment
├── manage.py              # Django CLI
├── django-app/            # Proje config
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
│   └── asgi.py
├── blog/                  # İlk app
│   ├── migrations/
│   ├── models.py
│   ├── views.py
│   ├── admin.py
│   └── apps.py
└── templates/             # Template dizini
    └── base.html

Settings Dosyasını İnceleme​

settings.py Django'nun en önemli yapılandırma dosyasıdır. PyCharm bunu açar; dikkat edilmesi gereken bölümler:

Code:
INSTALLED_APPS = [
    # Django built-ins
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Sizin app'leriniz
    'blog',
]

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

Geliştirmede SQLite varsayılan; üretimde PostgreSQL veya MySQL'e geçeceksiniz.

İlk Çalıştırma​

PyCharm'da Run → Run 'django-app' menüsünden veya yeşil "play" butonuyla geliştirme sunucusunu başlatın. Default port 8000'dir; tarayıcıdan http://127.0.0.1:8000/'i ziyaret edin.

Migration uyarısı görüyorsanız:

Code:
python manage.py migrate

Bu Django'nun built-in tablolarını oluşturur.

Superuser Oluşturma​

Admin paneline erişmek için superuser:

Code:
python manage.py createsuperuser

Username, e-mail, şifre soracaktır. Sonra http://127.0.0.1:8000/admin/'den girebilirsiniz.

Geliştirme Akışı​

Tipik bir geliştirme döngüsü:

1. Model değiştirmodels.py'a yeni alan ekle
2. Migration üretpython manage.py makemigrations
3. Migration uygulapython manage.py migrate
4. View yazviews.py'ya fonksiyon veya class-based view ekle
5. URL bağlaurls.py'ya path ekle
6. Template oluşturtemplates/'a HTML dosya
7. Test et — geliştirme sunucusunda görsel doğrulama

Üretime Geçiş​

Geliştirme tamamlandığında:
- DEBUG = False yapın
- ALLOWED_HOSTS'a domain'inizi ekleyin
- PostgreSQL'e geçin (SQLite üretime uygun değil)
- python manage.py collectstatic çalıştırın
- Nginx + Gunicorn ile servis edin

AIOR hosting paketlerimizde Django projeleri için PostgreSQL + Redis + Nginx + Gunicorn ön-konfigüre olarak gelir; deployment dakikalar içinde tamamlanır.


Django Project Wizard in PyCharm Professional​

PyCharm Professional ships with a built-in Django project wizard. The wizard sets up the virtual environment, installs Django, creates the initial project structure and hands you a ready-to-code dev environment. This guide walks through Professional's Django wizard step by step.

Creating a New Project​

Open PyCharm and choose File → New Project. From the project types on the left, select Django. If you don't see Django, you're on Community — in that case use Pure Python and install Django manually via pip.

Project Configuration​

Fill out the form:

Location: enter a meaningful directory path like /Users/me/Projects/django-app. PyCharm places all project files here.

Python Interpreter: select New environment using Virtualenv. Use a Python 3.10+ base interpreter. The virtual environment isolates this project — package versions here don't leak into other projects.

Application name: name your first Django app, e.g. blog or shop. PyCharm scaffolds this app along with the project structure.

Auto-Generated Structure​

After clicking "Create", PyCharm creates:

Code:
django-app/
├── .venv/                 # Virtual environment
├── manage.py              # Django CLI
├── django-app/            # Project config
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
│   └── asgi.py
├── blog/                  # First app
│   ├── migrations/
│   ├── models.py
│   ├── views.py
│   ├── admin.py
│   └── apps.py
└── templates/             # Template directory
    └── base.html

Reviewing settings.py​

settings.py is Django's most important config file. PyCharm opens it for you; the key sections:

Code:
INSTALLED_APPS = [
    # Django built-ins
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Your apps
    'blog',
]

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

SQLite is the default for development; you'll move to PostgreSQL or MySQL in production.

First Run​

In PyCharm, use Run → Run 'django-app' or hit the green "play" button to start the dev server. The default port is 8000 — visit http://127.0.0.1:8000/.

If you see migration warnings:

Code:
python manage.py migrate

This creates Django's built-in tables.

Creating a Superuser​

For admin access:

Code:
python manage.py createsuperuser

It prompts for username, email and password. Then sign in at http://127.0.0.1:8000/admin/.

The Development Loop​

A typical cycle:

1. Change model — add a field in models.py
2. Generate migrationpython manage.py makemigrations
3. Apply migrationpython manage.py migrate
4. Write a view — add a function or CBV in views.py
5. Wire URL — add a path in urls.py
6. Build a template — drop an HTML file under templates/
7. Test — verify visually in the dev server

Moving to Production​

When development is done:
- Set DEBUG = False
- Populate ALLOWED_HOSTS with your domain
- Switch to PostgreSQL (SQLite is not production-ready)
- Run python manage.py collectstatic
- Serve via Nginx + Gunicorn

AIOR hosting packages come with PostgreSQL + Redis + Nginx + Gunicorn pre-configured for Django apps — deployment completes in minutes.
 

Forum statistics

Threads
891
Messages
898
Members
27
Latest member
AIORAli

Members online

No members online now.

Featured content

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

Back
Top