I'm setting up a new Django app and need to customize the Admin for a given table by restricting the records where a field is NULL. Basically a built-in, permanent filter.
Seems like changelist_view needs to be overridden, but I'm uncertain what that change would look like.
There's no code to be included as I'm not overriding changeli...
Hi there!
I have a model with "disposals" and a model with "salesman".
I want to get the average discount of everye salesman.
Here's what I'm trying:
sm = Disposal.objects.annotate(average_discount=Avg('discount')).values('average_discount','sm__fname','sm__lname').order_by('-discount')
for s in sm:
data[0] = data[0]+s.sm_...
The following works great when going to the objects adminpage and select delete. The problem is that when using multiselect and deleting multiple items at once it doesn't use my delete-override. I've been looking for a solution but haven't found one so it's time to turn to the masters ;)
class Photo(models.Model):
name = models.Char...
Hi,
I have a model called Product with a custom property:
def _get_active(self):
o = get_option()
if self.date_expiration == None:
return True
if self.date_expiration <= o.working_month:
return False
return True
active = property(_get_active)
... and in one of my methods, I have this line:
products = ...
I'm attempting to use a similar Category implementation to this one in the Django Wiki. I'm wondering what the Django way of doing a search to pull all objects associated with a parent category. For example, if I have a category "TV" and it has subcategories "LED", "LCD", and "Plasma", how would I be able to easily query for all TV's w...
Hi, I'm currently on shared hosting plan with dreamhost and have installed Django as per http://wiki.dreamhost.com/Django . However, I also have a wordpress blog that I wish to keep running in a subdirectory, i.e, site.com/blog.
Is it possible to do this. Installing Django results in a passenger_wsgi.py file in the Django root directory...
I want a Registration Form with only email + password. I am thinking to insert automatically email in username field. So, for eash user, I will have this:
username: [email protected]
password: mypassword
email: [email protected]
Of course email + password will be used in login process.
Is it a good solution to having 2 fields...
I'm trying to fill in the value of a foreign key entry in one of my models using a value stored as session data...it all works well but when I try to access the record from the admin I get this error:
Caught an exception while rendering: coercing to Unicode:
need string or buffer, Applicant found
Where Applicant is the model linke...
Using the standard Django templating system, is there any snippet/reusable template tag to have the first n words in a piece of text wrapped in a tag so I can style them?
What I'm ideally looking for:
{{item.description|wrap:"3 span big"}}
which outputs:
<span class="big">Lorem ipsum dolor</span> sit amet, consectetur adipiscing e...
Both seems to be generating integer NOT NULL UNIQUE REFERENCES databaase columns.
Edit: My question is only about at the database level. (Not in the Django ORM.)
...
Hi all,
Background:
I'm starting to use Django for the first time, which is also my first foray into web development. I just got stuck on the whole "serving static media" problem. After spending a while looking at all the documentation and StackOverflow questions, I think I understand how it's supposed to work (i.e. MEDIA_ROOT, MEDIA_...
Hi!
Say my_instance is of model MyModel.
I'm looking for a good way to do:
my_model = get_model_for_instance(my_instance)
I have not found any really direct way to do this.
So far I have come up with this:
from django.db.models import get_model
my_model = get_model(my_instance._meta.app_label, my_instance.__class__.__name__)
Is t...
We are building a website on Google App Engine, using django patch.
We would like to use Facebook connect for two purposes:
Authenticate users.
Access user's social data.
Searching for a solution in the usual places (google, FB, SO) brigs up a lot of noise, many partial solutions and no clear answer.
So the question is this: does a...
I use clean_fieldname methods in my forms to validate data.
I use {{field.errors.as_text}} to output errors to templates. Every error message has an asterisk ("*" symbol) at the beginning of it. Is there any way to output validation messages without asterisks?
(No, I don't include asterisks myself, i just raise ValidationError(u'text'...
Hi,
I'm having a hard time trying to test weather a record in the database exists for a perticular ID in django.
something = User.objects.get(id=myID)
if something is None:
text="No Record"
I need to do something like this.
...
Hi I am new to Django working on Google App Engine.
class StudentAddress(db.Model):
name=db.UserProperty()
address=db.StringProperty(verbose_name='Home Address')
class StudentAddressForm(djangoforms.ModelForm):
class Meta:
moddel = StudentAddress
When the form is displayed, verbose name comes like this : Home address
Ho...
I want username field is automatically filled with this value:
username = str(n);
where n is a number ( autoincremented or random ).
.
I tried to add this in save method:
username = str(random.randint(0,1000000)
but there is a collision problem when n is the same for 2 users.
.
How do I do this ?
Thanks ^_^
...
I want username field automatically filled with this:
username = email[0] + str(id)
where id is the id of the user object
Is it possible ?
Thanks :)
...
Django doesn't support getting foreign key values from list_display or list_filter (e.g foo__bar). I know you can create a module method as a workaround for list_display, but how would I go about to do the same for list_filter? Thanks.
...
I have an application that will be used in the field for data collection, sending data to a central server running django. The user will be created on a website first, and then they will make submissions to that entry. However, I will protect the field application with a UUID to be sure the app only gets run on one machine.
The questi...