These are chat archives for django/django

Jan 2018
Jan 06 2018 07:40
@fccampelo Could you show me the TimeFieldMixin?
Amritpal Singh
Jan 06 2018 15:56
Hello everyone
I am deploying Django with gunicorn and Apache but I unable to serve static files. Here is my apache conf file.
<VirtualHost *:80>
    Alias /static/ /home/amrit/Sim/Sim_site/drawing_freecad/static/
    <Directory /home/amrit/Sim/Sim_site/drawing_freecad/static>
        Require all granted
    ProxyPreserveHost On
    ProxyPass /static !
    ProxyPass        "/" ""
    ProxyPassReverse "/" ""
This gives me 403 error (Forbidden
You don't have permission to access /static/ on this server.)
Jan 06 2018 17:34
hi @amrit3701
did you run 'run collectstatic' on the server?
Paul A. Aranguren
Jan 06 2018 20:52
Hey guys, I need help w/ showing images in the development server
for the life of me, I’ve tried every single combination
and I got it to work for a split second a few days ago, but I pushed to github and I overwrote everything, like a goober. So please, someone can spot my issue:
class catalogdb(models.Model):
    This is used to handle the actual themes for WP.
    name = models.CharField(null=False, max_length=20)
    dateAdded = models.DateField(auto_now_add=True)
    dloads = models.IntegerField(default=0)
    imgpocket = models.ImageField(null=False, upload_to='wpstore')
    filepocket = models.FileField(upload_to='themes')
    desc = models.TextField(null=False, max_length=500)
    categ = models.CharField(max_length=15, choices=CATE_CHOICES)
    new = models.CharField(max_length=7, choices=NEW_CHOICE)

    def __str__(self):
        return "{0}/\n{1}/\n{2}/\n{3}/\n{4}/\nNew:{5}/".format(
STATIC_URL = '/static/'
MEDIA_ROOT = '/Users/Paul/Desktop/data/python/django/wpdb1/cont/media'
MEDIA_URL = '/media/'
# html:
{% extends 'wpstore/index.html' %}

{% block content %}
<div class="container1">
  this is the catalog bro
{% load static %}
  {% for this in catalog %}
    {{ }}
    <br />
    {{ this.imgpocket }}<br /><br /><br />
  {% endfor %}
  <a href="{{ catalogdb.filepocket.url }}"> download here</a>
  <br /><br />
  {{ catalog.imgpocket.url }}
  <img src"{{ catalog.imgpocket.url }}" />
  <img src"{{ catalog.imgpocket }}" />
  <img src"{{ catalogdb.imgpocket.url }}" />
  <img src"{{ catalogdb.imgpocket }}" />
  <img src"{{ MEDIA_URL }}{{ catalog.imgpocket.url }}" />


{% endblock %}
and finally the views
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from django.template import loader
from datetime import time
import time
from wpstore.models import catalogdb

# Create your views here.
def index(request):
    return render(request, 'wpstore/index.html',)

def cataview(request):
    catalog = catalogdb.objects.all()
    return render(request, 'wpstore/catalog.html', {'catalog': catalog})
I just can’t get any image to show up on the dev server
Also, I have many img links linking images to see if there was a specific combination that could work.
Paul A. Aranguren
Jan 06 2018 20:58
one more, the urls
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import static, staticfiles_urlpatterns

urlpatterns = [
    path('', include('wpstore.urls')),

if settings.DEBUG is True:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)