I'm trying to display a bit of html in a message that's being displayed via the new Django messages framework. Specifically, I'm doing this via the ModelAdmin.message_user method, which is just a thin wrapper around messages():
def message_user(self, request, message):
"""
Send a message to the user. The default implementation
...
I'm looking for a way to store a number of points, zipcode and their latitude and longitude in a database, and given a query point Q's lat and longitude, find the set of the points in the DB that are within x miles of the point Q.
I realize something like a kd-tree would do the trick. I was wondering if there is any built-in python libr...
So in my Django project I have a few different apps, each with their own Models, Views, Templates, etc. What is a good way (the "Django" way) to have these Apps communicate?
A specific example would be a Meetings App which has a model for Meetings, and I have a Home App in which I want to display top 5 Meetings on the home page.
Should...
include mail Confirmation
thanks
...
Scenario:
class BaseClass(models.Model):
base_field = models.CharField(max_length=15, default=None)
class SubClass(BaseClass):
# TODO set default value if base_field's value is None
...
ie. I need to be able to load a fixture into the database, providing a default value only if the base_field is None. Any help greatly app...
Is it possible to import models from apps in different Django projects?
I hope to move some common models in a base projects from which every child projects can share the same data in these common models.
Edit
I have to place
from baseproject.appname.models import basemodel
before
os.environ['DJANGO_SETTINGS_MODULE'] = 'childproje...
I'm using Django and setting my CharField(max_length=255), even though I only intend to use about 5 characters. Is this less efficient? I've read that it doesn't really matter with varchar but then read that it'll save hard drive space to specify only what you need.
...
I have flatpage attached to multiple sites. Its admin preview chooses
arbitrary site, which is quite obvious after debugging up to lines 35-36 of
django.contrib.contenttypes.views.shortcut().
What would be the best way of fixing this problem?
I see that the shortcut() function takes a request object, so I could just extract host from...
Hi all,
I have this structure of model objects:
Class A :
b = models.ManyToManyField("B")
Class B:
c = models.ForeignKey("C)
d = models.ForeignKey("D)
Class C:
d = models.ForeignKey("D)
This is the query I'm trying to get:
I want to get all the B objects of object A , then in each B object to make comparison between the D object and...
Hello,
I have an application which is in BETA mode. The model of this app has some classes with an explicit primary_key. As a consequence Django use the fields and doesn't create an id automatically.
class Something(models.Model):
name = models.CharField(max_length=64, primary_key=True)
I think that it was a bad idea (see http://...
Hi,
I have a model with a CharField that earlier had "unique" set to True, but wich now is changed to False. But when i try to save that field with something that exists django still throws an IntegrityError.
How can i change this behavior so that it allows non distinct values?
The database is MySQL.
...
well it's quiet simple.
2 models with ManyToMany relation:
class Artist(models.Model):
name = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=100, unique=True,
help_text='Uniq value for artist page URL, created from name')
birth_name = models.CharField(max_length=100, blank=True)
c...
I'm trying to deploy my Django application to an Apache2 based server with mod_python. I've set the handlers right and made the configuration to make mod_python work with my project. My project implements a custom auth backend to connect my users to twitter, and my backend implementation is on:
myproject
|- backends/
directory.Everyth...
Hello.
I have 2 different tables in my database. They have some variables common and some different. For example:
Table1:
ID
Date
Name
Address
Fax
Table2:
ID
Date
Name
e-mail
Telephone number
I want to display data together sorted by date & ID but from both tables. For example, first displayed will be the newest record ...
In my webapp, there are a lot of errors or other messages that just show a template that is very close to the URL. At the moment, I have half a dozen static mappers like this:
(r'^/message/foo/$', 'direct_to_template', {'template': 'message/foo.html'}),
(r'^/message/bar/$', 'direct_to_template', {'template': 'message/bar.html'}),
Is t...
What are the worst mistakes made using Django framework, that you have noticed? Have you seen some real misuses, that maybe should go as warnings to the Django docs?
...
Following the reply to this question (Thanks again Ellie P!) I created a search page and a results page.
For instance if you search for the lawyer "delelle" the result page shows her firm, school and year graduated. But instead of displaying her info, I want to display other lawyers who graduated from the same school the same year.
T...
All,
I have a template page say x.html
i have 3 text fields name(varchar2) ,age(int),school(varchar2) in it.
If the users enters values in the form in x.html(say values name="a" ,age="2" ,school="a") and submit it.I need to return the same values back to x.html indicating an error.
My question is how to return the same values to x.ht...
Hi,
I have an Invoice model with a boolean field: is_overdue . This field is set to True if the user did not receive a payment and the due_date is before the date of today.
Now I want to accomplish that this field is regularly updated. Ok one possibility is to update the field when the save method is called.
But how can I ensure that...
Hello,
I'm trying to create a product code (in the admin) by combining elements from two other fields - one of which is a ManyToManyField. I'd like to iterate through that field to find out if a specific product option has been chosen, and append a variation of it to that non-editable product code, like so:
class ShirtColorClass(models...