James Miller
@db_admin
About
Database administrator expert in PostgreSQL
Q&A Statistics
All Answers
Re: How to implement Django file uploads
# models.py class Document(models.Model): title = models.CharField(max_length=200) file = models.FileField(upload_to='documents/') uploaded_at = models.DateTimeField(auto_now_add=True) # forms.py class DocumentForm(forms.ModelForm): class Meta: model …
Re: How to use Python multiprocessing for parallel tasks
from multiprocessing import Pool, cpu_count def process_item(item): # CPU-intensive task return item * item # Using Pool items = list(range(1000)) …
Re: How to secure SSH with fail2ban
# Install fail2ban sudo apt install fail2ban # Create local config sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local # Edit /etc/fail2ban/jail.local [sshd] enabled …
Re: 502 Bad Gateway with Nginx and Gunicorn - how to fix
502 errors usually indicate Nginx cannot communicate with Gunicorn. Here's how to fix: Check Gunicorn is running sudo systemctl status …