Browse all latest questions tagged Django
I want to pass a queryset from a view to a javascript function throught the template: my view.py: def myview(request): lista=Mymodel.objects.filter(tipo=mytipo) context_dict['lista']=lis...
Is there a way to show the SQL that Django is running while performing a query?
I'm using a custom user model, extended with AbstractUser. Here's my models.py: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models from django.contrib.a...
I was going through a Django tutorial, I was able to execute through the following steps creating a project, database setup the problem raised in development server step. I tried (venv)$ python manag...
I plan on creating a sidebar with changing elements (depending on the current url and authentication-status). For example: The default sidebar shows a login and a tag cloud. If a user is already lo...
I have made a custom profile model which looks like this: from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.ForeignKey('User...
I'm currently trying to create an API that return list of objects with page and limit per page input from url parameter using django-rest-framework which i already done in my api view with custom Pagi...
I'm getting a rejected error when trying to deploy a Django app to Heroku. I looked at possible solutions here: Heroku push rejected, failed to compile Python/django app (Python 2.7) Error pushing...
My Environment docker 17.12-ce python 3.6.3 django 1.10.8 I have a django application that I want to containerise. Trying to maintain best practice I have followed the advice to split the settings...
I've just started to use Django and I haven't found a lot of info on how to display an imageField, so I made this: models.py: class Car(models.Model): name = models.CharField(max_length=255) p...
models.py class Area(models.Model): area_name = models.CharField(max_length=255, null=False, blank=False) description = models.TextField(null=False, blank=False) class AreaPoint(models.Model...
I am having some trouble with migrating Django using postgresql. This is my first time with Django, and I am just following the tutorial. As suggested on the Django website, I have created a virtual...
I'm trying to test sent signal and it's providing_args. Signal triggered inside contact_question_create view just after form submission. My TestCase is something like: def test_form_should_post_...
I have a list of "news" headlines in a database with the following fields: ID, Title, Date. I want to get the ten latest ones (or retrieve all of them if there are less than ten). Something like: ne...
I'm using PyCharm 2018.2.4 with Python 3.7. I want to run some seed data so in the Python management console, I tried running my yaml file, which ended in this error [email protected]_project >...