I'm trying to build tests for some models that have a FileField. The model looks like this:
class SolutionFile(models.Model):
'''
A file from a solution.
'''
solution = models.ForeignKey(Solution)
file = models.FileField(upload_to=make_solution_file_path)
I have encountered two problems:
When saving data to a fix...
In our project, we have a bunch of different templates that clients to choose from (for their webstore). The file layout is something like this:
templates
cart.html
closed.html
head.html
standard
bishop
default
indiana
marley
mocca
nihilists
raconteurs
tripw...
I'm using Django Forms to do a filtered/faceted search via POST, and I would like to Django's paginator class to organize the results. How do I preserve the original request when passing the client between the various pages? In other words, it seems that I lose the POST data as soon as I pass the GET request for another page back to my...
Hello,
I'm sure this question is not specific to django, but since I couldn't find any solution for my problem in other questions about python and encodings, I'm going to ask this.
I need to add new features to existing website which is written in PHP using MySQL as backend. I inspected the database and created models for tables I am goi...
I'd like the user to be able to make multiple selections via the admin interface, and store the result as a list of comma-separated values. A select-multiple or a list of checkboxes would be great. However, I don't need the items in this list of values to refer to any models in particular... I just want a text list of items, plain and si...
I've been working with an open source project that it not working correctly in Production but does work in Development. I believe I will need to refactor part of the project.
The project has no tests, so I'm trying to learn how to use Twill to verify that my refactoring doesn't break the project during Development.
I also want to be ab...
I have a Django form that is subclassed from the django-contact-form application. I want to supply an initial parameter to the form (which will vary depending on context).
This code returns the contact form fine, but obviously doesn't supply an initial parameter, so I need to extend it:
def contact_form(request):
scraper_form = scrape...
Consider the following model:
class Message(models.Model):
other_model = models.ForeignKey(OtherModel) # OtherModel has owner field
thread_user = models.ForeignKey(User)
posting_user = models.ForeignKey(User)
message = models.TextField()
What I'm trying to do is have private messaging between two users on a third obje...
What are some RESTful ways to transition between pages of a multi-page form in Django?
My current method:
form POSTs to same page
form view validates and stores POST data in session
form view redirects to the next form page upon successful validation.
next form checks if previous data exists. if not, redirects to first form.
Are ...
I'm using django-registration to log users into my application. That part works fine. The part that I cannot figure out is how to set custom session variables when the user logs in. For instance, I'd like to populate variables containing UserProfile data as well as the output of a few other functions. Then I'd be able to use that inf...
I've been hunting around and Googling for examples, but I can't see an obvious best way to do an A-Z list of entries in Django.
I have around 2,000 placenames in a db. Rather than display them all on the same page, I'd like to have tabs or hyperlinks and an A-Z list of names.
Something like this A-Z list. Bonus points if it's possible ...
I want to implement Facebook connect login for my Django site and I've checked the already existing apps.
So far, I have found Django-Socialauth, django-socialregistration, and django-facebookconnect for this purpose.
The question is which one to choose, and I would like to hear from other developers who have experience with any of the...
So, the @cache_page decorator is awesome. But for my blog I would like to keep a page in cache until someone comments on a post. This sounds like a great idea as people rarely comment so keeping the pages in memcached while nobody comments would be great. I'm thinking that someone must have had this problem before? And this is different ...
In Django admin, how can I increase the width of the ManyToMany field's widget when using filter_horizontal?
...
Hello,
I am trying to implement django-facebookconnect, for I need to check if a user logged in via Facebook or a regular user.
At the template, I can check if user logged in via facebook by checking request.facebook.uid
such as:
{% if is_facebook %}
{% show_facebook_photo user %}
{% endif %}
For this, I need to pass is_facebook': re...
Hi,
Is there a method that I am not finding for getting the distinct hours in a DateTimeField? I essentially want the exact same thing that .dates() provides but for hours.
I should clarify that I am talking about a QuerySet method. The dates() method I am talking about is here:
http://docs.djangoproject.com/en/1.1/ref/models/querysets...
Hello,
I'm a Django newbie, so please forgive me if this is a stupid question. I have a search form that has multiple fields on it. I only wish to filter my queryset by those fields submitted that aren't empty. How do I do that? I'm aware you can chain querysets and Q objects together, but I don't know how to eliminate empty key/value p...
Sorry if this is a dumb way to ask this...
I have a generic list view for the homepage of a site, and would like to use a "homepage" model for informative text on that same page...is it possible? Thanks for your help.
models.py
from django.db import models
class School(models.Model):
school_name = models.CharField(max_length=250,...
My model is returning a Decimal(1234567.50), I can't seem to display the Decimal with a thousands separator. Does Django have a way to do this? Do I need to create my own template filter?
Thanks.
...
Hello,
I just want to add the subscription date in the User list in the Django CRUD Administration site.
How can I do that ?
Thank you for your help
...