226 questions
0 votes
1 answer
149 views
Django 1.4 How to customize elements inside MultipleChoiceField
I've set the widget on the MultipleChoiceField with: self.fields['field_1'] = forms.MultipleChoiceField( choices=[(c.name, str(c)) for c in customers], widget=forms....
1 vote
1 answer
838 views
How to increase visibility_timeout
We're using Django 1.4.22 and celery 3.1.25 with REDIS. The default value for visibility_timeout is one hour and it is too small for our jobs. How can we increase visibility_timeout to 6 hours? My ...
0 votes
2 answers
1k views
Django DoesNotExist - Matching Query doesn't exist
I'm working on a Django(1.4) and Python (2.7) project in which I have a custom model for user to get loggedin. Here's my model: from models.py: class User_table(models.Model): first_name = ...
0 votes
0 answers
52 views
Django 1.5 ImportError: No module named myproject.urls
Im trying to get a project working locally, however when I try and $python manage.py runserver I get the error: ImportError: No module named myproject.urls I am confident the project is set up ...
0 votes
0 answers
60 views
Why is my Django loading raw css into my html files?
I have a Django project which has been set us using django-pipeline and django-compress. The code on github is pretty standard ex: {% extends "base.html" %} {% load static from staticfiles %} {% ...
0 votes
0 answers
341 views
Django-cms template error in Django project
I'm trying to run locally old Django 1.4 project which I have to upgrade and further develop. Everything is working fine on server. On my local I've got virtual environment set up using pip freeze ...
0 votes
1 answer
104 views
Do QuerySet operations on prefetched relationships hit the database?
Let's say I query Workplaces in a City and prefetch all their Workers, which is a many-to-many relationship: workplaces = list(city.workerplace_set.filter(num_employees__lte=350).prefetch_related('...
1 vote
2 answers
2k views
Django: filter by aggregate
I am trying to filter by a value calculated using aggregates. Currently I am doing this: max_val = some_queryset.aggregate(max_val=Max('some_prop'))['max_val'] some_queryset.filter(some_prop=max_val) ...
0 votes
1 answer
39 views
Django 1.4 - query iteration using fields stored in a dictionary
I had a huge registration table with 112 fields. For a particular search I want to compare 17 fields & assign colors to variable say 'clrSelected'. My code is : reg = Regisration.objects.filter('...
12 votes
2 answers
15k views
Django QuerySet: filter by the value of another field
I have a model I wish to filter by its attribute a. The model also has another attribute b. I am trying to filter entries where a is 0 or a has the value of the b attribute (for each row, obviously). ...
0 votes
1 answer
2k views
user_passes_test: raise exception if user does not pass
I am trying to define a decorator to check if the user has admin certain privileges: def admin_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): actual_decorator = ...
2 votes
1 answer
2k views
How to convert string to django.db.models.query_utils.Q format?
For a search function I want to save django query to database & later execute it. I have saved the query as shown below in one table(Company, which have id,qryText). The django query is saved as ...
0 votes
1 answer
824 views
PIP install shows syntax error when specified version
When tried to install any dependency with specific version using PIP I am getting following error: (myvenv) D:\Project\on-staging>pip install Fabric==1.4.3 Collecting Fabric==1.4.3 Using cached ...
0 votes
2 answers
852 views
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 ...
0 votes
1 answer
3k views
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. ...