Newest django Questions

Q&A for professional and enthusiast programmers

Django latex template with images

I'm trying to generate pdf from django latex template. To do so I'm using the code from here: So I have this code in views.py context = {....} template = get_template('my_latex_template.tex') ...

NotImplementedError: HiddenField.to_representation() must be implemented for field

I have a embedded document field in our django-mongoengine model like this. I am using django rest framework. Models are like this : class ProjectExpertsList(EmbeddedDocument): Name = ...

Django multiple pluralization

Im quite new to django so can`t really figure out how to define multiple pluralization forms for some object. Here is my models.py from django.core.validators import MinValueValidator, ...

Do dynamically drop down filtering from queryset of a models.ModelChoiceField on a forms.Form

Hi I'm trying to build a drop down template where we can filtering. The order is the following one: University --> degree --> markDegree When we will choose a University in the following select or ...

Django DetailView with form for comments

I have this url mapping: url(r'^article/(?P<slug>[-\w]+)/$', views.ArticleView.as_view(), name='article-detail'), and I have this view: class ArticleView(DetailView): model = Article ...

Django template not displaying looped keys, values

I'm very new to Django and am trying to figure out why I can call the keys in a dict in my template as expected, but looping through the dict does not produce any text, nor any error messages. I don't ...

Django and docker, ImportError: Could not import settings '“config”' Is it on sys.path?

I'm step by step switching my django project to work on local from vagrant to docker. With docker, you don't need a virtualenv. Even if I find it very convenient I'm facing some new troublesome ...

Django 1.7 dumpdata on Windows scrambles unicode characters

I use manage.py dumpdata --format xml --some-more-parameters to export a full dump of the database to xml. The database is MS sql server and I'm using pyodbc as the driver. The dumpdata command is run ...

Django for loop in html template not displaying

So I am trying to get the latest post and I ran into a problem where it will not display the post views.py def latest_post(request): latest = Post.objects.all().order_by('-id')[:1] context = ...

sending json from django to d3.js

i am trying to pass a queryset in django's views.py to d3.js. views.py : def index(request): qs = DCPOWERSTATS.objects.all().values('TS','PuE').order_by('TS') return render(request, '...

Filtering with elastic-search and django

I've configured elastic search within my django project. The next step is to apply some filtering options of those searches. The content of each search is Cars, so I'd like to be able to filter on ...

Django: icontains case is sensitive for unicode

I'm making a simple search for my blog. I use an armenian language and when I'm searching it's always sensetive for these letters. Here is a part of my code. Thank you in advance. search_query = get....

Django custom prefetch and conditional annotate

I am using custom prefetch object to get only some related objects, ex: unreleased_prefetch = Prefetch("chants", Chant.objects.with_audio()) teams = Team.objects.public().prefetch_related(...

Django unable to find FULLTEXT index in mysql database?

The error that i am getting is OperationalError at /work/filter (1191, "Can't find FULLTEXT index matching the column list") Now what is strange is that i implemented them manually on database ...

Django Celery scheduled task django.core.exceptions.ImproperlyConfigured

I am trying to run my scheduled task with the following command: celery -A Htweetprod2 beat According to Celery 4.0 documentation to start the scheduled task this command should work, yet I am ...

Intersection of two django model?

I have two models and I want to find out the common sets of values on the basis of their ids First model: from __future__ import unicode_literals from django.db import models from django.contrib....

Ajax Requests Slow in Django

I have the following ajax request in my django template: $('#subjects').on('change', function() { var subject = $('#subjects').find(":selected").text(); $.ajax({ type: "GET", ...

How to disable checkboxes in MultipleChoiceField?

I use MultipleChoiceField in form. It shows me REQUIREMENTS_CHOICES list with checkboxes where user can select and add new requirements to database. Is it possible to disable checkboxes (in my case ...

django ajax post to unexpect url

my ajax as follow: <script> $(document).ready(function () { $.ajaxSetup({ data: {csrfmiddlewaretoken: '{{ csrf_token }}'} }); $("#submit").submit(...

Django MySQL Query Json field

I have a MySQL database with a table containing a JSON field called things. The JSON looks like this things = {"value1": "phil", "value2": "jill"} I have collection of objects that I have pulled ...

Django cache and usernames

So I have this site (Django 1.8) which has a master template where the name of the logged-in user is displayed, so the template contains {% if user.is_active %} {% trans 'Welcome,' %}{% filter ...

Ctype Windows access violation writing 0x74616455 OR crash

I use Ctype in my Django project but when I use this method : def requete_smartphone(self, bande, debut_a, debut_m, debut_j, fin_a, fin_m, fin_j, sens, fvitesse, fstat, affmes, min, max, moyenne, ...

retrieve data from a django model When a users payment is overdue by 2 days

I am trying to retrieve data from my payments model, When a users payment is overdue by 2 days. The below code is what I have already tried . expected_payment_date = datetime.date.today() + datetime....

How to handle Referer in https post reuest in ionic app with backend django?

I am new to ionic development.I am developing an ionic app with backend django. I have write code for login and signup in django project and I deploy the app into heroku.the django app heroku url ...

Django migrating from MySql to Postgres fails user authentication

I changed the database from MySQL to Postgres. after migrating all data password checking for all users fails. I am using AWS RDS, Is this because of Postgres peer authentication? and if so how can I ...

What is the “Best Practice” for invoice calculations in Django 1.10+?

If one has two models: class Invoice(models.Model): class Meta: ordering = ('-date_added', ) number = models.CharField(max_length=10,) comments = models.TextField(blank=True, ...

Django html template in a seperate file

My question is more of an etiquette theme rather than anything else. I'm developing a relatively small application that reads XML data and writes to an Oracle DB and outputs to a webpage. I'm ...

Getting 502 Bad Gateway while running the Django application within a docker container?

Those are the following steps I am following to run my application within a docker container . docker run -i -t -d -p 8000:8000 c4ba9ec8e613 /bin/bash docker attach c4ba9ec8e613 my start up script : ...

PostgreSQL query slow, what's the issue?

I'm trying to store some measurement data into my postgresql db using Python Django. So far all good, i've made a docker container with django, and another one with the postgresql server. However, i ...

How to get List from Django Model (instead of Map of fields)

I have a Model called Patient. In this table I have a field:id and condition. So, If I want to get the ids given the condition, I can use this following syntax. ids = list(Patient.objects.filter(...

Django group by month name

I want to get an output of {'month': 'jan', 'count': 1600} but I get the following with the current code {'month': 1, 'count': 1600}. How do I do this so I get the name of the month and not the ...

Django static files do not resolve constant 404 errors

I am new to Django current version I'm running is 1.11 with python 3. I have configured the static file stuff as the docs suggest. Inside installed apps I have 'django.contrib.staticfiles' ...

Django: Bokeh.safely is not a function

I was trying to embed a bokeh plot into my django app. I followed the instructions given on Bokeh website and another question. I am getting the following error on my browser console and not getting ...

How to put disabled attribute inside input?

In my form I use MultipleChoiceField. It shows data from tuple CHOICES. forms.py: CHOICES = ( ('A', 'Name A'), ('B', 'Name B'), ('C', 'Name C'), ) class SomeForm(forms....

Fail to Deploy the Django App in the Heroku Cloud

I was trying to deploy a Django app in the Heroku following the official instruction. The project structure is as following, It's good to mention that, I can run heroku locally from the src folder, ...

ValueError: invalid literal for int() with base 10(Django)

error in cmd Code I tried to create a project where to manage a garage, but when I create the model in application"utiliser", I got this problem. Thanks!

How to pass parameter to view method using {% 'url' %} syntax in django

In my url.py: url(r'hardware/common_report/(?P<line_id>[a-zA-Z]+)', 'Report.views.hardware_common_report', name='hardware_common_report'), In my view.py: def hardware_common_report(request): ...

Install mysqlclient for Django Python on Mac OS X Sierra

I have already installed Python 2.7.13 Django 1.11 MySQL 5.7.17 I want use MySQL with Django, but after install mysql connector I was try to install mysqlclient for Python on $ pip install ...

duplicate key value violates unique constraint “wagtailcore_page_path_key” DETAIL: Key (path)=(0001) already exists

I am working on a system that has been developed by someone else based on Django and wagtail. I managed to import data to postgresql but I believe not everything was imported since I get an error when ...

Serving Django CMS Admin Styles in Production with Apache

I made a simple site using Django CMS. Everything seems to work, except for the styles on the admin toolbar. They are not loading. What should I do to configure the app or server to serve them ...

Django-Javascript Modal form validation

I have form in django, which accepts number between 1 and 6 (option list) and multiple image files. The form is modal, so I cannot pass in any errors with Django, because modal closes on refresh. Is ...

Dynamically generated form choices in Django

I have a form for submitting new articles in Django, in this form you're allowed to place the post into a 'user_group', just a many many relationship between groups and users. However, you're only ...

How can I select records n-at-a-time for multiple users to edit?

I am using a Django backend with postgresql. Let's say I have a database with a table called Employees with about 20,000 records. I need to allow multiple users to edit and verify the Area Code ...

DRF, caching for as_view()?

In my view, I often use APIView's as_view() to generate json. I'd like to cache the response and tried the following but it won't work def some_complex_view(self, request, *args, **kwargs): ...

Local field 'created_at' in class 'Attachment' clashes with field of similar name from base class 'Timestampable'

I have the following two models: class Timestampable(models.Model): created_at = models.DateTimeField(null=True, default=None) updated_at = models.DateTimeField(null=True, default=None) ...

Calling a Stored Procedure using django-mssql

I'm trying to call a stored procedure on a multi-database project I am working with. I have 2 of my stored procedures working, but this particular stored procedure is not working and returns an error: ...

django-allauth: Verification email not sent on SignUp

Hello I am using allauth with: custom Django user: class Profile(AbstractUser) Custom Signup form: class ProfileForm(UserCreationForm) Alluth account adapter: AccountAdapter(DefaultAccountAdapter) ...

Django - Serve files for download

I have a collection of documents(.pptx files) that I wish to make available for download to users. I am using django for this purpose. I have some parts figured out using these links: having-django-...

Page not found with Django (404)

in my django project,when i access localhost:8000 it say: Page not found (404) Request Method: GET Request URL: http://localhost:8000/ the urls.py is: from django.conf.urls import ...

create site as alltop.com with django [on hold]

way or package for create a site example site: www.alltop.com with framework django. for Implementation of these sites with Django framework, what measures should be taken? this site alltop use rss ...
Translating... 0%