Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Django Settings
DEBUG=True
DJANGO_SECRET_KEY=your-secret-key-here-change-in-production
ALLOWED_HOSTS=localhost,127.0.0.1

# Database
DATABASE_URL=sqlite:///db.sqlite3
# For PostgreSQL: DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# Email Configuration
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-password
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Django
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
/media
/staticfiles
/.static_root

# Environment
.env
.env.local
.env.*.local

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Python
*.egg-info/
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual Environment
venv/
env/
ENV/
env.bak/
venv.bak/

# Cache
.cache/
.pytest_cache/
*.cover
87 changes: 87 additions & 0 deletions DJANGO_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Django Project Setup & Getting Started

## Project Structure

```
arch-vim/
├── config/ # Django project configuration
│ ├── settings.py # Main Django settings
│ ├── urls.py # URL routing configuration
│ ├── wsgi.py # WSGI application
│ ├── asgi.py # ASGI application
│ └── __init__.py
├── apps/ # Django applications directory
├── templates/ # HTML templates
├── static/ # Static files (CSS, JS, images)
├── media/ # User-uploaded media files
├── manage.py # Django management utility
├── requirements.txt # Python dependencies
└── .env.example # Example environment variables
```

## Quick Start

### 1. Create Virtual Environment
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

### 2. Install Dependencies
```bash
pip install -r requirements.txt
```

### 3. Setup Environment Variables
```bash
cp .env.example .env
# Edit .env with your configuration
```

### 4. Run Migrations
```bash
python manage.py migrate
```

### 5. Create Superuser (for admin access)
```bash
python manage.py createsuperuser
```

### 6. Start Development Server
```bash
python manage.py runserver
```

The site will be available at `http://localhost:8000`
Admin interface: `http://localhost:8000/admin`

## Creating a New Django App

```bash
python manage.py startapp your_app_name apps/your_app_name
```

Then add to `config/settings.py` under `INSTALLED_APPS`:
```python
'apps.your_app_name',
```

## Database Configuration

By default, the project uses SQLite. To use PostgreSQL:

1. Install: `pip install psycopg2-binary`
2. Update `.env`:
```
DATABASE_URL=postgresql://user:password@localhost:5432/arch_vim_db
```
3. Update `config/settings.py` to use the DATABASE_URL

## Production Deployment

- Change `DEBUG=False` in `.env`
- Update `ALLOWED_HOSTS` with your domain
- Use a production-grade database (PostgreSQL)
- Use `gunicorn` as WSGI server
- Set up proper static files with `python manage.py collectstatic`
1 change: 1 addition & 0 deletions backend/media/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# .gitkeep - Keep this directory in git
Empty file.
8 changes: 8 additions & 0 deletions backend/media/mysite/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


import os
from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_asgi_application()
120 changes: 120 additions & 0 deletions backend/media/mysite/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""
Django settings for arch-vim project.
"""

import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'django-insecure-change-this-in-production')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', 'True') == 'True'

ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')

# Application definition
INSTALLED_APPS = [
'colorfield',
'django.contrib.admin',
'admin_interface',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'showcase',
]

MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'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 = 'mysite.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'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 = 'mysite.wsgi.application'
CORS_ORIGIN_ALLOW_ALL = True

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

# Password validation
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
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True

# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [BASE_DIR / 'static']

# Media files
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

# Default primary key field type
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'root': {
'handlers': ['console'],
'level': 'INFO',
},
}
7 changes: 7 additions & 0 deletions backend/media/mysite/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('showcase.urls')),
]
6 changes: 6 additions & 0 deletions backend/media/mysite/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_wsgi_application()
2 changes: 2 additions & 0 deletions backend/media/showcase/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Sample Django app structure
# Create your apps using: python manage.py startapp app_name apps/app_name
Empty file.
Empty file added backend/media/showcase/forms.py
Empty file.
9 changes: 9 additions & 0 deletions backend/media/showcase/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models


class Task(models.Model):
title = models.CharField(max_length=100)
description = models.TextField(blank=True)
completed = models.BooleanField(default=False)
def __str__(self):
return self.title
7 changes: 7 additions & 0 deletions backend/media/showcase/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework import serializers
from .models import Task

class TaskSerializer(serializers.ModelSerializer):
class Meta:
model = Task
fields = '__all__'
22 changes: 22 additions & 0 deletions backend/media/showcase/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.urls import path, include, re_path, reverse_lazy
from django.views.generic.base import TemplateView
from rest_framework.routers import DefaultRouter
from .views import TaskViewSet

from . import views


app_name = 'showcase'

from django.contrib.auth import views as auth_views


router = DefaultRouter()
router.register(r'tasks', TaskViewSet)
urlpatterns = [
path('', TemplateView.as_view(template_name='index.html'), name='index'),
path('', include(router.urls)),
]
7 changes: 7 additions & 0 deletions backend/media/showcase/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework import viewsets
from .models import Task
from .serializers import TaskSerializer

class TaskViewSet(viewsets.ModelViewSet):
queryset = Task.objects.all()
serializer_class = TaskSerializer
1 change: 1 addition & 0 deletions backend/media/static/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# .gitkeep - Keep this directory in git
Loading