Category "django"

If statement on a Model.field

hopefully this is clear. I am trying to put together a view that takes care of what happens when a user places a bid on an active listing on the auction site I

How to assign items inside a Model object with Django?

Is it possible to override values inside a Model? I am getting 'MyModel' object does not support item assignment. my_model = MyModel.objects.get(id=1) print my

Can't run the server on Django (connection refused)

I finally (think) installed successfully PostgreSQL and also de psycopg2 (I use Windows). Btw, is some way to check it's working properly? Well, the thing now

Django websockets and channels group_send not working

I started looking into websockets and I would liek to implement realtime communication between web-client (Angular 13) and Python app. As backend I used Django

Getting Value of Selected Nav Pill

I'm trying to make a pair of nav pills to choose between a graphical and a tabular output for a set of data and I can't seem to figure out how to grab the value

How do I reset PYTHONPATH to "default" value in virtualenv?

I was struggling with installing dependencies for an external library (the requirements were already fulfilled) when I read that I should check if the install p

Equivalent of using if .. else as an expression in the Django Template Language

In Python, there are two ways to use if and else: either for Boolean flow control, in which case it is used with colons and indentation, or as an expression on

Django Static - Google Cloud Storage - CDN

I am still new with serving my Django static/media files to Google cloud storage. It's working now but I am not sure if this is right or is this enough already,

raise RuntimeError('You need to use the eventlet server. '

In my project, I created a app: the website_chat/views.py code: async_mode = 'eventlet' import os from django.http import HttpResponse import socketio ba

Django somehow accesses the static files even after i had deleted the whole static folder

I am new to Django, I had placed the static files in the project level static folder and even in multiple applications inside the app/static/app directory. Ever

command "django-admin.py startproject mysite" not recognized

EDIT: I added the path to django-admin.py to my system path (C:\Users\me\Downloads\Django-1.5.1\django\bin) but even after this when I try to run django-admin.p

how to use google login link to my login page using django-allauth?

I have created a project which is working nicely. I have a login page, signup page and profile page (as myspace). I just want to add an additional funtionality

request.FILES always empty on file upload

I am totally stumped on this, and must be doing something incredibly stupid. I am trying to simply upload a file on a Django project. The problem seems to be th

Running Django on Google Colab

I was trying to run the Django on Colab, by following the instruction here, however, after the !python manage.py runserver step, I tried to access the server

Setup Django Postgres database

I created the django app, I have it connected to my local server with pgAdmin3. I want to have the django app push to bitbucket. But the problem is: How do I s

When testing Django REST Framework, why can't I get APIClient.credentials() to authenticate using a token?

I'm writing a functional (not unit) test against a basic API, like so: from decouple import config from rest_framework.test import APIClient, APITestCase clas

How Django set path to files

In a django project, I want to open a file "file.png" (from images folder) in "worker.py". worker.py images file.png otherfile.png It works well using the te

Django 2.0: sqlite IntegrityError: FOREIGN KEY constraint failed

I'm working on adding Django 2.0 support to the django-pagetree library. During automated testing, using an sqlite in-memory database, I'm getting a bunch of er

LEAD and LAG window fucntions in Django orm, how to apply on single object?

Question is regarding Window functions usage in Django. I have a following model: class EntriesChangeLog(models.Model): content_type = models.ForeignKey(

ugettext and ugettext_lazy functions not recognized by makemessages in Python Django

I'm working with Django 1.5.1 and I'm experiencing some "strange behaviour" with translations. I'm using ugettext and ugettext_lazy in the same Python file. If