Django template with multiple models

I have a template from which I need to render information from multiple models. My look something like this: # from django.db import models class foo(models.Model): ''' Foo content ''' class bar(models.Model): ''' Bar c...
more »

2017-01-16 19:01 (2) Answers

Django object.filter is not loading all results

I am using Django 1.10.4 and MySQL 5.7. So, I have following models: class Image(models.Model): request = models.ForeignKey(Request, on_delete=models.CASCADE) customID = models.CharField(max_length=128, null=True) status = models.Intege...
more »

2017-01-16 10:01 (1) Answers

Last activity field in Django's user sessions

How and when exactly does last_activity in Django sessions get updated? I've been testing a Django app, and my last activity in user sessions is logged as several days ago, even though I logged in yesterday as well. What could be going on? ...
more »

2017-01-16 00:01 (1) Answers

Greenplum Django migrate distribution key error

I am currently working on a Greenplum project. Part of this project is creating a simple webapp for the visualization and statistics of data. When I tried integrating Greenplum with Django it failed, giving me the following error: python manage....
more »

2017-01-15 21:01 (0) Answers

Django static media not showing picture

after searching for a solution for hours which did not resolve my problem,I am posting this. The image from my media root is not showing up on my html. In chrome's console i get a 404 file not found.Even though the image is there. I am using Python 3...
more »

2017-01-15 12:01 (1) Answers

How to join tables in django

Please excuse me for this silly question, I'm a beginner and I can't find my way through documents. I have two models: class Student (models.Model): name = models.CharField(max_length=40) family = models.CharField(max_length=40) ...
more »

2017-01-15 12:01 (2) Answers

Django app deploy to Heroku, Application Error,

I am struggling to get my Django 1.10 app deployed to Heroku. Just as a preface, I am using Pycharm and had to rename my project at one point, but it refactored and changed the name in all places so I'm hoping that's not related to the issue. When I ...
more »

2017-01-13 23:01 (1) Answers

How to pass an url tag in a custom template tag?

I'm learning Django building a small site, and I found that I have many templates where I list objects, each of them with a link to it. I thought I could make a custom template tag, something like {% object_list some %} some is a dictionary {'lis...
more »

2017-01-13 16:01 (2) Answers

How to package a Django app to be test-friendly?

I've been working on this side project that's effectively a replacement for Django's default FileField and ImageField classes. More of a thin wrapper really, it lets you change this: attachment = models.FileField(upload_to="attachments") im...
more »

2017-01-13 15:01 (1) Answers

How to query by string

In Product model and i want to query by food title. and return me NoReverseMatch error html url: <a href="{% url 'product' food_name=catalog.food_name|urlencode %}">some text</a> def product(request, food_name): product...
more »

2017-01-13 09:01 (2) Answers

Django, form is_valid() is always false

I'm learning Django and have some troubles with forms. I try to create a simple form where I type a name and show it on another page. But is_valid() always returns false. Please, help me to find my error from django import forms class Ord...
more »

2017-01-12 18:01 (2) Answers

Getting Error, But the package is installed

I am trying to set a little report system up on the system to allow admin to produce reports as Csv documents. I found Django-import-export installed it changed my INSTALLED_APPS, everything worked. If there was no module names import-export im gues...
more »

2017-01-12 15:01 (1) Answers

Django proxy model to different database

Situation We have a few different applications which use tickets from a ticket support system for different kinds of functionality. First of all we have an application which has a few models that represent the models of our ticket support system ...
more »

2017-01-11 12:01 (3) Answers

pip install Django on python3.6

If I run pip install Django I get Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pip syntax to install t...
more »

2017-01-11 11:01 (5) Answers

add link to Actions in Django Admin

In Django admin I have a print button that sends information to the template. I want to add to the Action dropdown link where I checkboxes select the desired entries and in Action dropdown choose Print. But when I added a link to the Aсtion dropdo...
more »

2017-01-11 08:01 (1) Answers

Adding user to group on save in Django 1.9

Hello, I'm using Django 1.9. Trying to add a user to group on creation or save. Using either user.groups or groups.user_set.add don't work, mix and match with pre- and post-save below. These answers aren't working for me, and so this isn't a dupe: A...
more »

2017-01-10 17:01 (1) Answers