Newest django Questions

Q&A for professional and enthusiast programmers

Django: how to pass object between views when pickle serializer fails

I need to be able to pass my object solo between view functions. Presume that the problem with solo is that it opens a TCP but not sure. So, what's a way to pickle solo, or how could I do this ...

Need Help to display images from model

I have a model named 'Page' and i want to store many images for each Page object. So i created a Separate Model named 'Image' as a F.K of 'Page' model. In my template,, i am displaying all the Page ...

Django Object to Create a New Google Maps Marker

There are several online posts with others trying to accomplish the same thing, but none that provided a solution. I have a database of veteran memorial plaques and one of the variables is a map grid ...

How to have extra django model fields depending on the value of a field?

I have a model in my Django project called Job. Each Job has a category. An example of a category could be tutoring. This can be represented as what my model looks like right now: from __future__ ...

ogrinspect: "CommandError

I was following geodjango's tutorials and got stuck at the ogrinspect command. Some heads up: I have included django.contrib.gis in INSTALLED_APPS I have gdal (2.1.0) library installed in my ...

url.py in django, what does ^ do? [duplicate]

So ive just started learning django and im currently messing around with the urls.py file. I was wondering if someone could explain to me what the "^" at the start of the url does? I posted some code ...

How to localize Django website

I have a website developed using Django. I want to offer language switcher option to translate the site to another language. Is there any plugin (like Google Language Translate for WordPress Site) or ...

Django Order Ascending & Descending

Let say, I want to order the Threads by total Votes, Views and Comments. But they order models is instanced from Thread model. here is my models.py class Thread(models.Model): .... rating = ...

Transient use of Django Model instances

I have a use case where a particular class can either be transient or persistent. Transient instances are build from a JSON payload on a PUT call, and may either be persisted to the database or used ...

axios request to django REST framework causes error “Error: Permission denied to access property Symbol.toPrimitive”

UPDATE: Installed chrome and its working fine. problem is with firefox I have a django REST app and I'm using react+redux for my UI. I tried to get these working together by the way explained in ...

Deploying a Django App to App Engine Flexible Environment

I am trying to deploy a sample app to the Google App Engine Flexible Environment based on this tutorial. The deployment works, however, the application cannot start up. I get the following error ...

Chain queries in parent Models

I have a bunch of different Models that access different tables in a database and are chained to each other by inheritance as follows: class Food(models.Model): # Some unique fields and ...

Post with CSRF protected cookie, Jsoup

I would like to scrape the following web-site using Jsoup. As far as I understood, its back end is written using Django and the CSRF protection is enabled. In order to load more elements, the user ...

Reverse error in Django 1.10

I'm new to Django and slowly learning how it works. I just upgraded to 1.10 and part of my app stopped working. I know it is related to the changes made into Reverse. I have been reading and I cannot ...

custome user serializer giving error on is_valid() - django

For some reason I am not using form model to create the user form and so on so I am not using the form.is_valid() I went through online and was taught to create a serializer like this from django....

How to make redis BROKER_URL dynamic on deployment to AWS instance

I'm deploying a Django app which uses celery task and has redis as the broker backend. I'm using docker for deployment and my production server is an amazon aws instance. The problem I'm facing is ...

Embed an interactive Bokeh in django views

I want to make interactive plot in django views (or model ?). Let's say I want to use selection_histogram example. I think Bokeh fit my needs because, I have matplot/seaborn that I can reuse and I'm ...

Django select field with thousands of choices creating thousands of database queries

I have two models, model B and model C, which both extend model A. In a form I have a model select field for model A - this obviously loads all instances of model B and C which was my intention. ...

How to display specific navbar when logged in?

I have created 2 navbars, one for when user is logged in and one for when they are not. I need to display the correct navbar dependending upon if the user is logged in or not. I know i need to check ...

Django 1.7.1 dumpdata progress bar

I have an existing project in django 1.7.1, but from django 1.9.1 a new feature had been introduced in the dumpdata command (--output) python manage.py dumpdata --output backup.json On executing ...

Autodoc Sphinx with django error

I get an error when I try to make html with autodoc. Here is my project structure : projet --- app1 ------ models.py ------ views.py --- app2 --- app3 docs --- modules ------ models.rst --- conf.py ...

Django Rest Framewrok api how to add Authecation permission for all

I've followed tutorial provided here exactly. http://www.django-rest-framework.org/tutorial/1-serialization/ But all my snippets are being viewed even there is no log in. How to prevent this? I've ...

Using returned JSON object before redirect in Django? SocialAuth

I'm pretty new to Django and using python social auth. I'm trying to use a specific API to do social auth. My url redirects the user to the company's site for authorization. The URI takes me right ...

Django store original file name and generate new name

I have a 'beginner' problem with Django. In my models.py file I have the following class: class File(models.Model): user = models.ForeignKey(User) uploaded_file = models.FileField(...

Copy template in a test file

In Django, I'm trying to copy the content of a template in a test file with python manage.py dumpdata --indent=2 configurations.template | >> test.txt command, but it didn't work. Could anyone ...

Django apache Python3.5

I use a bunch of Ubuntu 16.04 + Apache 2.4 + Django 1.10 + Python3.5 + wsgi + virtualenv. Everything works but for some reason, use Python 2.7.12, and I need 3.5 On the page of the site is written ...

Django-views.py: How to perform the inner join

I have the two following models: class Table1(models.Model): locker_id = models.IntegerField(primary_key=True) locker_name = models.CharField(db_column='Locker_name', max_length=45, blank=...

ModelForm doesn't manage instance model as I need

My problem is that I want to manage dialogue attributes using ModelForm. Now I need to realize adding in dialogue participants and changing name of dialogue. I tried to do it using code below but when ...

How to skip validation for Django Field in ModelForm with Select2?

I have a form in models.py of my django project: class Profile(models.Model): choices = (("choice1", "choice1"), ("choice2", "choice2"), ("choice3", "choice3")) field = models.CharField(...

how to smart update a value based on heavy calculation every n seconds (performance)

In django we have a Task model that contains a 'progress' Float field. This progress float field is calculated based on some calculation of related outputs (Output model). We use a trigger (using ...

NoReverseMatch when rendering page

I seem to know where the issue is located since I can get around it, but for getting around it I have to sacrifice a function I really want to keep. Here is the relevant code in the non-working state:...

How to write Nested DRF Serializer with two foreign key fields

Suppose I have Django Models as follows: class Car(models.Model): name = models.CharField() model = models.CharField() type = models.CharField() class Scooter(models.Model): name = ...

Django: How can I remove all stored messages?

I used django message framework only in one view(PasswordChangeView). Problem is that when I access to PasswordChangeView, this page shows all message in message storage such as Login successed, ...

Django EmailMessage send() works and then gives HTTP Error 400: Bad Request

I have two forms on my clients site; one on the homepage and one on the contact page. I will test the forms one minute and they work fine and then I'll test again at later and I get HTTP Error 400: ...

django ajax javascript not working

1. I'm trying to add ajax to my django web application... The code i've written is given below... for testing i wanted to display a text in the html element whose id="id_ajax1"... the code ...

Vesta panel Django

I want to run Django using Vesta panel. I tried it using Apache and using Nginx. Everywhere does not come out, no access. Tried the instructions from the website https://www.digitalocean.com/...

Getting error: type object 'x' has no attribute 'objects', while defining custom queryset and model

I am facing difficulty in integration of custom manager and queryset for django models with django-rest. I have defined a custom manager named 'manager'. But rest_framework requires that manager must ...

Django: accessing properties between classes and performing math on them

I'm currently learning Django... Upon making a pledge, the user can choose a reward. The reward has a value and a deductible value. For example: there may be a reward worth $50 but only $40 of it is ...

Redirect to different App view directory from urls.py

I have URL definitions in my wagtail blog's app directory(blog/urls.py), and I would like to reference a view in my search app directory (search/views.py). The current URL definition is url(r'^search/$...

Django default value

If I create a field as typed below, will the default value be saved to the object, when the field on the form leaved blank? field_name = models.FloatField(default=100.0, blank=True)

ValueError: needs to have a value for field “” before this many-to-many relationship can be used

Django Version: 1.10.4 Exception Type: ValueError Exception Value: "<SchoolBook: 0 test1 Test2 Test3 2011 122>" needs to have a value for field "schoolbook" before this many-to-many ...

Django custom authentication syntax error

I am trying to upgrade my Django project to 1.10, but I am hitting this brick wall when implementing custom email authentication. I have followed the instructions on django docs, but it keeps ...

Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python 2.x

I'm running on macOS 10.12, and I'm trying to install Django using: pip install Django==1.10.5 I get this error: Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running ...

How to create nested comment system with django-mptt

I'm working on simple blog and I'm trying to implement a nested comment system for each post. I created model for comments and it's works fine via Django Admin Page. I don't know how to create form ...

lookups that span relationship. - Do all my model names need to have first capital letter

So I am currently learning about querysets and models in django. I was guided to this article from SO which states Lookups that span relationships Django offers a powerful and intuitive way to ...

How to print meaningfull error messages to the user through JsonResponse and Django

I am trying to print something relevant to the user using this Django code: try: //do things return JsonResponse({}) except Exception as e: msg = "There was an error processing your ...

Updating deployed django project

If I need to update deployed Django Project, can I just only delete old app_name folder and paste new app_name folder from local development, or migrations will crash in this case, therefore I am only ...

Trying to configure a django application to use mod_wsgi

I keep receiving this error in the apache error.log when I visit the URL for this project: [Fri Jan 20 21:04:16.143990 2017] [:error] [pid 18618:tid 140192977487616] [remote 66.90.146.30:326] ...

redifine method delete or destroy in modelviewset of Django Rest Framework

I have a special delete, so I cannot just use DELETE method. this is the model: class PersonalDetail(models.Model): icon = models.URLField(_('icon'), max_length=500, blank=True, default='') ...

Django ImportError 'No module named '

I'm trying to run a django app but hitting this error when trying to load the page from the browser: No module named views The offending line in urls.py is from landpage.views import txt The file ...
Translating... 0%