Newest 'django-1.4' Questions

Q&A for professional and enthusiast programmers

Redirect to home page with arguments after submiting form in django

I am trying to add details of students,which is submitted using django & 'POST' method. On submission I save the details in my 'py' file. After that I want to redirect to home page. Earlier I ...

'WSGIRequest' object has no attribute 'Post'

I am new to django and python and I am trying to update the database boolean field from checkboxes in the html page. when I try to access the checkboxes in the views method, this error occurs: '...

Django: psycopg2 import error

I was having a very weird bug when trying to run migrations in my freshly installed Django app and narrowed it down to the module imports. I found out django.db.backends.postgresql_psycopg2.base wasn'...

Django: custom HTML tag

I want to clean up templates where something like this is very frequent: <div class="some-class {% if x %} {% if x.a %} class_x_a {% else %} class_x_b {% endif %} {% elif y %} class_y ...

Running django test on the gitlab ci

I have project in django 1.4 and I need to run django test in contious integration system (GitLab 6.8.1 with Gitlab CI 4.3). Gitlab Runner have installed on server with project. When I run: cd ...

How to search in ManyToManyField

I am new to django, and I am trying to make a query in a Many to many field. an example of my query: in the Models I have class Line(models.Model): name = models.CharField("Name of line", ...

Error loading MySQLdb module: No module named MySQLdb

i am getting this error when running python manage.py syncdb. I've tried installing all the packages that were described in various posts to no avail.I desperately want a solution as i have lost too ...

Django 1.4 import error No module named apps

I am running a django app on Windows server 2008 R2(64 bit). The same app works fine on my other system which has windows 7 64 bit. I am actually trying to move the app to the other machine. I am ...

django.db.utils.DatabaseError: (1146, “Table 'test_xxx.django_content_type' doesn't exist”)

I get the following error when I run the django unittest. python manage.py test ... ... django.db.utils.DatabaseError: (1146, "Table 'test_xxx.django_content_type' doesn't exist") Please guide me ...

Is there a way to define multi-field index without index_together Meta option?

I am working on a legacy django project that uses django 1.4. For a new model I tried to add a multi-field index with: class Meta: index_together = [ ["user","is_read"], ] It ...

Django 1.4, mongoengine.django.sessions: cannot import name Connection

I'm new to Django and working off of someone else's code that hasn't been worked on in a while. python manage.py syncdb --settings=mysite.settings_local File "/Users/hkwik/.virtualenvs/env/lib/...

Is Getting started with Django (Django 1.4) tutorial ok for Django 1.9?

Does anyone know if it makes sense to go through this tutorial with django 1.9, even though the tutorial is based on 1.4 Is there an updated version of http://gettingstartedwithdjango.com

Passing Parameters to An Overrode View in Django/Allauth

With Django 1.4 and Allauth, I'm trying to have 2 different signup pages. When I say different, I mean 2 different URLs and 'html layouts'. Here's what I did so far. It 'works', but it doesn't pass ...

Django delete all cookies for all users

I have the django view to set the value in cookies 'no_show_dialog' when a user clicks 'Don't remind me anymore' in the modal dialog. Now i changed that dialog completely and want to reset that ...

NoReverseMatch for '' in django URLs

NoReverseMatch at /login/ Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] I've located what I think is the error in urls.py urlpatterns = ...

2 Different Templates for Django With Allauth

I'm using Allauth with Django 1.4. What I need to do is to create 2 different signup templates. The template HTML has to change, but it's basically the same displayed fields. What I tried to do is ...

go back to prev version of Django

by mistake I installed Django 1.7, and now I have compatibilities issues, so I'd like to go back to Django 1.4 but don't know how. Anyone can point me in the right direction?

Change of 'QuerySet' from Django 1.4 to 1.7

I'm trying to port an app from Django 1.4.15 -> 1.7.3 I've come to a problem where the app have a method in models.py def is_votable(self, user): ''' Decides if the user can vote for ...

Django Subquery Error

I made a migration from Django 1.4 to Django 1.8 and now i have a problem that i dont know how to solve. When i run: dd_interface = D_Interface.objects.filter(C_INTERFACE__iexact=interface....

ascii' codec can't encode character u'\xa0' in position 0: ordinal not in range(128)

i dont know where i went wrong but when i am trying to write into a excel file with the object which having the database values it is showing the above error. in my views.py ast = Asset.objects....

Intermittent ImportError with Django package

I have the following import line in a Django 1.4 project running in Python 2.7.6: from django.contrib.gis.utils import GeoIP This line works just fine 100% of the time in production and in ...

Django: broken migrations

I am trying to setup a Django app locally in a new machine but migrations seem to be totally broken. They need to be performed in a particular order, which worked in the first machine I set the ...

django.views.i18n.javascript_catalog in script

I am trying to use below code. But getting error. Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] I am copying this code from django1.4 to django1.9 ...

Django: cannot import name migrations

I had an issue I just posted here. I saw an answer to a similar question which said uninstalling and installing requirements.txt would help because the root of the issue was a bad dependency chain. ...

How can you display the results of a script in real-time for a Django 1.4 website?

So after finding out how to display the results of scripts on a Django website, I thought I'd be able to display the likes of live CPU information using SAR however whenever I change my code and ...

Django - How to Save ImageField Even if Form is Not Valid

I have a fairly standard model and form. I have some mandatory fields with an ImageField. When the user choose an image and doesn't field the mandatory fields, the image isn't saved and the user needs ...

Test an app created in django 1.4 for compatibility with django 1.7

I have an existing application developed in django 1.4. I want it to upgrade to django 1.7. I can make the changes if some modules are deprecated since i don't need the backward compatibility. For ...

Django query with AVG and GROUP BY

My Django-foo isn't quite up to par to translate certain raw sql into the ORM. Currently I am executing: SELECT avg(<value_to_be_averaged>), <id_to group_on> FROM <table_name> ...

Django decorator unresolved reference

I created a decorator to return JSON from a view, however when using it ontop of the method I am getting an unresolved reference. This is the decorator: def json_response(func): def decorator(...

Reverse not found for my custom model admin urls after reload(sys.modules['urls.py'])

After doing following when I call reverse for my custom model admin url its giving me Reverse not found and before reloading urls.py reverse working fine. def _reset_urls(self, urlconf_modules): "...

Django doesn't recognise keyword blank on child of forms.Form

I'm trying to create a form that will receive empty strings in some of its values. This form is not backed by a model object. I've defined it thus: class SearchForm(forms.Form): device = fields....

email.send() taking forever for manual connection

django 1.4 version I know about send_email. But, I need to set manual connection for every email from db so using send() function. from django.core.mail import EmailMessage, get_connection e = ...

Django manage.py do not show commands of an app

I'm using Django 1.4 and have a project similar to the following: project/ __init__.py app1/ __init__.py models.py views.py management/ __init__.py ...

Count unique dates from a multidimensional list

I am querying a database for Leads. Leads have a "lead generated date" and a possible "closed" date. What I would like to do is get a month by month total for leads generated/leads closed per month ...

django STATIC_URL variable is empty

Pretty popular question on here... My template is rendering, but the {{ STATIC_URL }} variable is either empty or non-existent. I am using django 1.4. Using the variable in my template: <link ...

Convert a list or a raw set to a queryset

In my django views, I have the following code in my CBV: def get_filtered_queryset(self, queryset): filtered_queryset = # some code here document_queryset = # some code here return set(...

Django Nose ImportError: no modules named urls

I started using django-nose because I wanted to to run only my apps' tests via python manage.py test, but I'm running into this ImportError: no modules named urls. This project is using Django 1.4. ...

Django datetime localization

I want to output a datetime object (with timezone info set to UTC) in a Django template. I have I18N, L10N, and TZ support all on in the settings. I've also added the LocaleMiddleware and set the ...

Django: decorator in class based view

I want to restrict access to a particular view so that only AJAX requests are accepted, so I implemented the following decorator: def require_ajax(func): def decorator(func): def inner(...

ImportError db_scripts: No module named db_scripts

I am trying to run Class2go project from Stanford, but as the project is a little bit old I received many errors. I solved most of them but the following error made me crazy. I will be most grateful ...

skip all ModelForm validation conditionally but include it all otherwise

I have a form that has a selector at the top where a user can select none, or choose a couple options where the validation varies depending on the selection. If they select none, then it needs to ...

NoReverseMatch not a registered namespace, django 1.4 issue

I am forced to use django 1.4 to use neo4j, and I am getting a strange message that "accounts" isn't a registered namespace. It most certainly is, right there in the root: from django.conf.urls ...

How to use template within Django template?

I have the django template like below: <a href="https://example.com/url{{ mylist.0.id }}" target="_blank"><h1 class="title">{{ mylist.0.title }}</h1></a> <p> {{ mylist.0....

Django model form saves m2m after instance

I am having an issue with the way Django class-based forms save a form. I am using a form.ModelForm for one of my models which has some many-to-many relationships. In the model's save method I check ...

upgrade from django 1.4 to 1.7 - url tags error (I think!)

I am trying to upgrade my version of Django from 1.4.6 to 1.7, but I get the following error, which I have no idea how to solve: My tracestack is as follows: C:\Users\user_name\Desktop\project_name\...

Django: distutils errors when installing requirements.txt

I am trying to setup my app in a fresh computer but I am having trouble installing the requirements.txt file. It fails when trying to install this package in particular: django-generic-m2m==0.2.2 I ...

How to write join conditions in django query

I want to know how to write a join condition in django query for the following SQL query: SELECT s.name, l.name, a.name, a.asset_code, c.name, ad.name, a.model_no, a....

list index out of range error when saving objects in admin after upgrade from Django 1.4 to 1.6

I have recently upgraded my 1.4 project to 1.6 and after working out some of the deprecation problems I have reached another one that I have not been able to solve. Every time I either try to save a ...

Django fixed number of Formset with sub-keys

Let's say you have books that have a series of sale prices in different currencies. The list of currencies to be used is fixed but may be changed later (ex. in settings.py). I'd like to generate a ...

Django 1.4.5 . Field relation

I am new to django framework. I have 2 models: class A(models.Model): name = models.CharField(...) position = models.PositiveSmallIntegerField(...) ... class B(models.Model): myfield ...
Translating... 0%