133 questions
0
votes
0
answers
139
views
Add a column from another object to an existing listview
I have an existing listview and I want to add a new column(contactDate) from another object which will be soratble. I want to sort my LeftListView by the contact_date of the Action each Left record ...
0
votes
0
answers
341
views
Django ORM extra with multiple returns
Is there a way in Django 1.3.7 to return multiple values from one extra select?
For example I have two extra selects used to get two separate values, and i would also like to get their difference (I ...
0
votes
2
answers
114
views
Django upgrade from 1.2.5 to 1.3 error in admin
I am attempting to upgrade a website running django 1.2.5 to 1.3
The only error I have encountered so far is in the admin part of the site:
__init__() got an unexpected keyword argument 'field_path'
...
0
votes
1
answer
4k
views
Switch Case in Django Template
I'm trying to put different template for different category based on category ID. I'm using Django 1.3. Switch case is not working with Django 1.3, I get this error:
Invalid block tag: 'switch', ...
-1
votes
1
answer
51
views
django/south : redundant add_column?
I made a change, adding a unique constraint to a model, within the abc application and did a
./manage.py schemamigration abc --auto
That created a migration file but as well as the expected change ...
0
votes
1
answer
27
views
Uploaded Files Not Available Django 1.3
I'm working on making a job application page with Django 1.3 (I know that I should update but that part is out of my hands) with apache through mod_wsgi and am running into issue when users try to ...
0
votes
0
answers
302
views
How to override password change form in django 1.3?
I must use django 1.3 and I have:
class CustomPasswordChangeForm(AdminPasswordChangeForm):
def clean_password1(self):
passwd = self.cleaned_data['password1']
if passwd and len(...
0
votes
1
answer
41
views
django product of annotate
Django 1.3 Python 2.7
I have the following models (irrelevant fields omitted):
class Encounter(models.Model):
subject = models.ForeignKey('Subject', to_field='uuid')
uuid = models.SlugField(...
1
vote
1
answer
1k
views
django count annotation field
Django 1.3, Python 2.7
I have the following models (some irrelevant fields omitted):
class Encounter(models.Model):
subject = models.ForeignKey('Subject', to_field='uuid')
uuid = models....
0
votes
1
answer
403
views
Django count number of times each ForeignKeyField value appears in table & retain __unicode__()
Django 1.3, Python 2.7
I have the following models (some irrelevant fields omitted):
class Encounter(models.Model):
uuid = models.SlugField(max_length=36, unique=True, default=make_uuid, editable=...
0
votes
1
answer
221
views
How do I authorize separetely from authentication using django-auth-ldap
I am creating a django application that need to authenticate against our organization's LDAP server which I have successfully done using django-auth-ldap. After authentication, I need to authorize ...
0
votes
1
answer
108
views
Want to know the raw sql query when user other than superuser logs in the system
I have an application which involves large number of users.
among those, some are staff members.
My problem
When a user from a certain group let say A logs in, it takes 5 minute to see the admin
...
0
votes
1
answer
157
views
Django won't recognize my static files on my dev machine
I've been tasked with fixing some aspects of a django 1.3 site, that runs on Apache/PostgreSql on the server. I'm trying to set it up on my development machine, with a virtual environment with ...
0
votes
0
answers
157
views
django admin form - display radio button to control save_model?
In an application adding 'customer' objects the user enters 'shipping' and 'billing' addresses. If the billing address is not added the save does not validate.
I'd like to change this so that user ...
1
vote
1
answer
555
views
'Meta' object has no attribute 'abstract'
I have this error :
**'Meta' object has no attribute 'abstract'**
It happened after I installed a new django app, it updated django version to 1.5, I changed it back to 1.3 but I still have the ...
0
votes
1
answer
2k
views
Django foreign key is not set and hence unable to save form
I have a simple foreign key relationship between two tables. I am able to save the parent, but am unable to save the child which has a foreign key to the parent. This is what my models look like:
...
0
votes
1
answer
40
views
Django 1.3 authentication
We have digest authentication in our application. For some reason we are seeing for a few users having different id, username as in "auth_user" table but for some reason in the ...
1
vote
1
answer
361
views
Queryset in ModelForm is properly limited initially, but not when form is submitted with errors
I want to limit a queryset for a form based on the user sending the request. I am having some trouble getting a ModelForm to properly limit the queryset of a field when the form is submitted but ...
2
votes
1
answer
440
views
Django 1.3 testing without recreating database / loading fixtures for every run of the test
I'm using django 1.3 and writing some selenium test & django unit tests. I want to know if its possible to run the tests without creating the databases & loading fixtures everytime?
I ...
0
votes
2
answers
132
views
Django staticfiles and CSS and javaScript
I'm using django 1.3 for production and want to use static file's in my CSS and javaScript but it doesn't work , I don't have any problem in my HTML ! how must solve this problem ? I didn't find any ...
1
vote
0
answers
114
views
Programmatically set the model on a class based view in Django 1.3
I'm trying to implement a more generic version of the Django class based detail view, which can operate on different models when required. The idea was to set the model using a parameter in the URL, ...
1
vote
1
answer
2k
views
Error : Invalid block tag: 'else', expected 'empty' or 'endfor'
I'm currently doing some starting stuff on Django 1.3.1 and following error struck me for 2 hours. Help me in figuring out the error. I have included my code on bitbucket.
Error:-
...
0
votes
1
answer
615
views
Django 1.3.1 - Unhandled exception in thread
I' currently doing django from some video tutorial. I had difficult to figure out the line which forces to following error.
Validating models...
Unhandled exception in thread started by <bound ...
0
votes
4
answers
2k
views
Django: Static files missing when rendering template
I am using django 1.3 and trying to deploy a django project (client sent) on my dev machine (ubuntu 12.04). The problem is regarding the static files. My directory structure is as follows:
...
1
vote
1
answer
2k
views
django Error : Caught ImportError while rendering: No module named comments
I am currently porting over some django 0.97 code to django 1.3.1 code.
I keep getting the following django error:
TemplateSyntaxError at /dir1/dir2/
Caught ImportError while rendering: No module ...
0
votes
1
answer
134
views
Batch union of django querysets
I'm trying to get a single queryset from the output of a recursive function and i am hitting a performance problem.
Basically it seems that the act of trying to combine the individual querysets is ...
0
votes
1
answer
790
views
Django custom manage.py commands calling functions in app
I have a command which is used to download data from an API, and then store it into a local database, it's currently part of my app but I want to add the ability to run it from a manage.py command.
...
0
votes
2
answers
33
views
Retrieving the name of the class which powers a model field
I'm handling some edge cases in some django code, and i'm hitting a problem that is only encountered when specific fields are involved.
I want to be able to detect the class that the Model is using ...
6
votes
3
answers
12k
views
Saving a decoded temporary image to Django Imagefield
I'm trying to save images which have been passed to me as Base64 encoded text into a Django Imagefield.
But it seems to not be saving correctly. The database reports all my images are stored as "" ...
0
votes
0
answers
574
views
How to call a Python function within a Backbone.js view?
I'm working on a project that's in the process of migrating from Django 1.3 to Node/Backbone.js
Consequently, I'm working with two sets of views. I have a function for validating and processing ...
0
votes
1
answer
185
views
Django 1.3 Pagination Not Showing Page Links and Showing all Records
I'm trying to set up Django Pagination in Django 1.3, It doesn't seem to be working, as I have over 5 records returned and the links are messed up
View:
def directory(request, ...
0
votes
0
answers
86
views
Django CSRF validation, when it's not turned on?
I'm trying to post some data from one python application to a django site using urllib, as they are separate programs.
Now i don't have CSRF middleware enabled and I've specifically got @csrf_exampt ...
2
votes
1
answer
608
views
Add a function as a field to a model in Django/Python
Models
class A(SiteAwareModel):
name = models.CharField(max_length = 255, blank = False)
description = models.TextField(blank = True, null = True)
class Meta:
def key_count(self)...
1
vote
1
answer
2k
views
How to get user's Timezone in Django 1.3 Http Request
I have read that there is a lot of timezone support available in Django 1.4, but how does one obtain user's timezone in Django 1.3?
Once I have the timezone i.e. something like 'Europe\London' or '...
1
vote
2
answers
580
views
South won't migrate my custom field
I have a model which has a nullable foreign key relation with itself (this 'self' can be any model which has this foreign key). This foreign key is a custom class which prevents cyclic relationships.
...
0
votes
2
answers
150
views
Django: using {{STATIC_URL}} from python side
Building a "history" system that serves static pages based on the date the user asks for. Not all dates have associated pages, and it isn't possible to know, based on what's in the database which do, ...
0
votes
1
answer
1k
views
How do I know which child class a Django model object is when selected through the parent class?
I have a main Event class, and four event types. Each of them is a subclass of (at least) Event. On an event's detail page, I am adding a link back to the admin interface for a given event to save the ...
2
votes
2
answers
2k
views
Filtering for multiple ForeignKey matches using Q objects
I've initialized these models with the following data in an app named main under Django 1.3:
from django.db.models import Model, FloatField, CharField, ForeignKey, Q
class Customer(Model):
name =...
1
vote
1
answer
554
views
Deliver cached page to anonymous user and non-cache to authorized
I'm using django 1.3 in my app. I need to organize caching, which satisfies following rules:
using memcached as cache backend
using @cache_page decorator in views, which I want to cache
each non-...
3
votes
2
answers
2k
views
blank=False,null=False not working in models code Django
class Url(models.Model):
url=models.URLField(verify_exists=True,max_length=200,blank=False,null=False)
date=models.DateTimeField(auto_now_add=True)
count=models.IntegerField(default=0)
...
0
votes
1
answer
644
views
How to convert modelchoicefield to charfield in django admin?
This is my sample model:
class Booking(models.Model):
email = models.EmailField(unique=True)
first_name = models.CharField(max_length=256)
last_name = models.CharField(max_length=256)
class ...
0
votes
1
answer
488
views
Update a count variable in model object
What I want to do is simple I want to update the count variable of the object every time my view function is called.
My models is like this:
class Url(models.Model):
#some vars here
...
0
votes
2
answers
3k
views
Change site address http://127.0.0.1:8000/ to something like http://www.google.com [closed]
How can i change the default address http://127.0.0.1:8000/ to something useful like a proper sitename.
I am using the development server that comes with Django.
I googled for about 1 hour but ...
0
votes
1
answer
2k
views
how to override django admin form Foreignkey based on request.user
admin.py
class PromoAdmin(admin.modelAdmin)
list_display = ( 'name', 'id', 'category', 'promo_type', 'store', 'brand', 'date_start' )
form = SampleForm
forms.py
class SampleForm(forms....
2
votes
1
answer
2k
views
Function-based generic views have been deprecated
DeprecationWarning: Function-based generic views have been deprecated; use class-based views instead.
I keep getting this warning, when I'm running my site. What does this mean and how can I fix it?
1
vote
2
answers
2k
views
Set new `path` value for ImageField
I have the following situation. Project files was stored in ~/django-apps/app-old/app. For some reasons I move files to ~/django-apps/app . Application have some images, stored with use of ImageField. ...
2
votes
2
answers
4k
views
Django 1.4 deprecates ADMIN_MEDIA_PREFIX but my project was started using Django 1.3 so having issue while using in Django 1.4
I started a project in Django 1.3 and have recently installed Django 1.4 on another machine and continued my project on Django 1.4.
Django 1.4 deprecated the ADMIN_MEDIA_PREFIX setting so I removed ...
2
votes
1
answer
370
views
apache 500 internal error when updating from django 1.3 to 1.4
Originally when I installed Django 1.3 with wsgi on my ubuntu server I used the included setup.py file and so when I wanted to update followed the Remove any old versions of Django section of the ...
3
votes
1
answer
129
views
Django: `model.fk_id` isn't updated after `model.fk.save()`?
I've got a model which, when saved, should create and save one of its foreign keys if it doesn't already exist:
class MyModel(m.Model):
fk = m.ForeignKey(AnotherModel)
def save(self):
...
0
votes
1
answer
513
views
Pre-Fetching one-to-many records in Django 1.3.1
I am looping over a queryset and fetching a one-to-many field. Now, for each call there is a query that is being fired. Django 1.4 has prefetch_related. How can I do something similar with Django 1.3....