Newest django Questions

Q&A for professional and enthusiast programmers

Django Apache mod_wsgi - Unable to open database file

After upgrading mod_wsgi to the latest version, my app can no longer access its caching db (sqlite). The Apache error log shows the following: mod_wsgi (pid=1050): Target WSGI script '/location/...

Get the image (picture) of an django database using django-image-cropping and easy-thumbnails

I have an django installation with the plugins django-image-cropping and easy-thumbnails in use. I want to add users pictures to there vCard using vObject. models.py: (...) class Person(...

Django - User creates User and Profile in same form

Hi have changed my view from this: How to make User able to create own account with OneToOne link to Profile - Django For some reason the profile_form is not saving the 'user' information to the ...

Django error: Reverse for 'details' with arguments '()' and keyword arguments

Here is part of my django app and I want to create link with get_absolute_url but I get an error: Reverse for 'details' with arguments '()' and keyword arguments '{'slug': 'product'}' not found. 0 ...

Summing two char Case-expressions results in integer result

I have a Django 1.9 project in which I try to concatenate two Case expressions like this: .annotate(aggr_field= Case( When(my_field1__isnull = False, then = F('my_field1')), ...

How to populate hidden fields with data I got from another form in Django?

I have a very simple form, form1 [Rendered on template1] that takes in text for a required field. Clicking Submit on this form will lead to form2, [Rendered on template2]. On template2, I also display ...

In Django, is it possible for superusers to have different required fields than non-superusers?

I know that superusers and regular users are both just django's User objects, but how can I write a custom user class that requires some fields for plain users and doesn't require those fields for ...

Customizing Django Sitemap Index

I have created a sitemap index in Django that links to three other sitemaps. The default sitemap index template looks like this: <?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="...

Django REST permission does not return 403

I am now creating a testcase on Django REST3.5 Here is my tests.py Problem: It returns 201 instead of 403. I do not want the object be created import os import pytest from rest_framework.test ...

Mongoengine, django and firebase user authentication? [on hold]

I would like use part of firebase and join with mongoengine and django. It's posible this ?. Help me.

Uploading pictures in Django fields and calling that file in HTML

My name is Luca and this is my first post, I've been working on a little project lately. I solve flight deals for people and would like to upload a screenshot for every deal I solve so that the client ...

Python - Pulling Large (millions) of records from a postgremysql Database Compess while file is still generating

I am writing a large number of records, probably 2 million records in a text file(zip). I would like to do that in chunks. I would to stream the data out of the database, rather than load it in all at ...

configure react js and python in the same project

I have a project on react js and python (Django). I would like to know what is the best way to configure them. I don't know much about react so any suggestion is welcome

Django and Python 3, If POST value equals not working

from datetime import datetime, timedelta from django.utils.dateparse import parse_date I'm trying to be able to either request database logs from either a set period of hours, or a custom time range. ...

django database functions cumulative count?

is their a way to create cumulative count using/customizing django database functions. this built-in query gets the number of items for each year. what if we need the number of items before that year ?...

Django: How to make an API call just before browser tab close?

I am using Django v1.10 for an application where in need to send an API call just before browser close through crude javascript (don't want to use any library for sake) preferably. I've read about ...

Starting multiple processes in Celery

I have a problem with configuring Celery for Django. This is how I start django-celery: python manage.py celery worker --autoscale=10,2 Example of a task: @task def test(i): print "ITERATION {}...

Django Form transport

I created a file forms.py. I added to it CartTest class that retrieves data from the database to form. I added to the view cart_detail form then added to the template this form. What should I do so ...

Facebook Login in Django Backend with big Frontend separation.

I'm trying to make a login with Facebook. What I want is to create and endpoint and use it as I use the "standard" email login endpoint, since I need a big separation between the backend and the ...

Python 3.5 - Django 1.8 - after login {{ next }}

I am currently learning Django by reading a popular book for this framework called "Django by example". Currently, I am at the 4th chapter and even though I can managed to follow the instructions, I ...

Having trouble serving image from django rest API using angular

I am currently having an issue rendering an image from my newly created products API using Django REST Framework. I have everything else loading but the images will not load. I am using angular to ...

How to create a field in MySQL that get data from the callable function in Django?

How can I set a django field that gets data from a function depending on other fields? Let me explain using the following example. class Test(models.Model): def testType(self): return str(...

Nginx cache static files from different aplications

I use WordPress as a home page (mysite.com) and Django for the rest (mysite.com/pages). I have single nginx config file for both of them and its working fine. Moreover, they reside in a single server ...

please help me in understanding a django based project

link to project is:- https://github.com/amangoeliitb/Photo-Gallery-Web-Application I am trying to understand this django based project. I was not getting why he has created two folders i.e eversnap ...

Django client does not delete in test

Hi I am now using Django REST3.5.3. I can do CRUD perfectly fine with browsable API. My problem is my test does not pass. tests.py import os from django.test import Client from apps....

Django migration default value callable generates identical entry

I am adding a new field to an existing db table. it is to be auto-generated with strings. Here is my code: from django.utils.crypto import get_random_string ... Model: verification_token = ...

Refresh super'd model fields via views.py — Django

I have a site which catalogs local hikes, and gives user points for each hike they go on based on how difficult that hike was. Here's what I'm looking to do: Grab each user For each user, grab all ...

Getting Started with Tastypie: no such table: myapp_entry

Just like the title of the page says, I'm Getting Started with Tastypie by following the linked tutorial. But when I try to load /api/entry/?format=json, I get HTTP 500 response, with this error ...

Two Foreign keys issue django

Hi I have this python code for django, and basically i am trying to build it so that every tourobject can have many tourbets but also i want to be able to save a certain winning tourbet as current bet ...

ClusterTaggableManager Not Saving Tags in Django Wagtail CMS

Not sure if I can use it this way, but I have a Price model that I am using ClusterTaggableManager for the name object. The Price model then has an Inline relationship to my Product model. The tag ...

django queryset element can't be changed?

def cumulate(self, dataset): nb = 0 for i in range(dataset.count()): nb += dataset[i]['nb'] dataset[i]['nb'] = 99 print(dataset[i]['nb']) return dataset why this ...

Django Angular JS integration

I have a django working app in which I use a terminal command to display a database, this command is written in a function inside models.py In addition, I have an html template that uses angular.js ...

Working around SQLite's lack of named parameter support

Django's documentation on objects.raw() says the following about using named parameters: Dictionary params are not supported with the SQLite backend; with this backend, you must pass parameters as ...

How do you handle cross origin with Angular 2 + Django during development?

I'm using Angular CLI to run my SPA during development. It launches a dev server directly in memory with hot reload and all cool stuff. I'm using Django as my back-end and Django has its own ...

Using Django SMTP

After reading the docs on the Django website, I'm a little confused on how to configure the SMTP backend with my Djagno application. I have a local exchange server that is running a business domain ...

How to run Django with Python 3.5?

After source ./bin/activate, on doing a which python3.5 I get the following response /path/to/virtualenv/bin/python3.5 I am using Django 1.10.5 which according to their documentation supports Python ...

How do I add custom CSS to crispy forms?

I'm trying to create a responsive form for my website with the help of crispy forms.I'm not using bootstrap and I want to add custom CSS to the crispy form to match my whole website. HTML: <form ...

Passing Request to Django form Still shows self not defined

I am currently using Python and Django to make a Web Application. As my title states I am trying to pass the request down to one of my form classes so I can use user data. I know there are a lot of ...

How can I approach data split across multiple databases?

I'm putting together a proposal for the development of a web application. The app is to be launched in multiple countries, and some of the client's partners and (allegedly; I'm no lawyer) some of the ...

Trying to make a cart using django but in views I am passing product id rather than slug because I am adding product to cart directly from homepage

Cart App views.py from django.shortcuts import render, HttpResponseRedirect from django.core.urlresolvers import reverse # Create your views here. from products.models import Product from .models ...

How to fetch data from three table in django?

I am trying to fetch data from three tables in which one is parent table and another two are OneToOne realted tables. My Table structure is as follows: Parent Table: class Request(models.Model): ...

Multiple Databases --Migrations

I am using 2 postgres databases in my django app. 'newpostgre': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'new_postgre2', 'USER': 'tester', 'PASSWORD': 'password',...

Getting field value from django database

I have an staticmethod where I save user (if exists) and calculation. @staticmethod def save_calculation(user, selection, calculation_data): customer = None if ...

call to custom create_user via form fails

I have a form that I am going to be using for user registration and want to use the same create_user function that is defined in my custom user manager, however, when the user data is submitted, the ...

django objects.filter(x__in = y) where y is repetitive QuerySet

Customer.objects.filter(customer_id__in=contact_list_senders) contact_list_senders is a repetitive QuerySet that involves some customer_ids: {sender_id1, sender_id2, sender_id1, sender_id2, ...

Prefetching One-to-Many Relationship django ORM

I am working on an API function right now that would return a list of a users friends as well as all of the references for that users photos. (Although I only need the reference sorted by ord) Below ...

Field not found on serializer

I'm building a REST API using DRF, and am currently stuck with modeling the endpoint /api/v1/venues/1/packages/. A GET request on this is giving me this error: AttributeError at /api/v1/venues/1/...

Manipulating Django form to show the correct validation error(s)

In a Django form, I'm getting users to input their usernames. The field is like so: username = forms.RegexField(max_length=50,regex=re.compile('^[\w.@+-]+$'),\ error_messages={'invalid': _("(...

How to use Django to run python scripts?

Sorry for the super basic question. I have a simple python script with a function that takes string inputs, makes a list, and prints out the length of the list. I wanted to see if I could use Django ...

Nginx redirects to default page

I am setting up a domain for my Django/Gunicorn/Nginx server. It works fine with IP address instead of domain name in server_name but when I add domain name it redirects to default Ubuntu Nginx page. ...
Translating... 0%