Now I have this code:
attitude = request.REQUEST['attitude']
if attitude == 'want':
qs = qs.filter(attitudes__want=True)
elif attitude == 'like':
qs = qs.filter(attitudes__like=True)
elif attitude == 'hate':
qs = qs.filter(attitudes__hate=True)
elif attitude == ...
Say you have an Events model that contains information about the event. But what about things like slugs, titles and meta description that would go into the html?
It would seem like such things properly belong as attributes to a Page model rather than to an Events model.
Is there a correct way to do this? What are the pros and cons of...
Fresh from the Djangobook tutorial using the Books app example, you have Book related to Author through a many-to-many relationship and Book related to Publisher. You can get a set of books associated with a publisher with p.book_set.all(), but what do you need to do to get a set of authors associated with a publisher (through the books ...
I have an admin view which contains four foreign keys each with a few thousand entries. It is slow to appear in the browser.
If I change the django model to eliminate the select boxes by adding raw_id_fields things become nice and snappy. So the slowness is due to the population of the select drop downs and also this is a known issue s...
I have a Django application that I would like to deploy to the desktop. I have read a little on this and see that one way is to use freeze. I have used this with varying success in the past for Python applications, but am not convinced it is the best approach for a Django application.
My questions are: what are some successful methods ...
I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as [email protected]) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool with it. What I'd ...
I came across 2 different modules for porting django to appengine.
http://code.google.com/p/app-engine-patch/
http://code.google.com/p/google-app-engine-django/
Both seem to be compatible with django 1.0,
The featured download of the latter is in Aug 08, whereas the former is Feb 09.
What are the relative merits.
What if I dont use...
I'm trying to prepopulate a ModelForm and an inlineformset_factory with an instance of a Model, BUT when the user submits the form, I need to create a new instance of the Model and it's related child records.
Example Model:
class Artist(models.Model):
artist = models.CharField(max_length=100)
class Song(models.Model):
artist =...
I'm building a website using Ubuntu, Apache, and Django. I'd like to block people from filling out and submitting a particular form on my site more than once. I know it's pretty much impossible to block a determined user from changing his IP address, deleting his cookies, and so on; all I'm looking for is something that will deter the ca...
Short version:
Is there a simple, built-in way to identify the calling view in a Django template, without passing extra context variables?
Long (original) version:
One of my Django apps has several different views, each with its own named URL pattern, that all render the same template. There's a very small amount of template code that...
Hello!
I am trying to make Django view that will give JSON responce with earliest and latest objects. But unfotunately it fails to work with this error.
'str' object has no attribute '_meta'
I have other serialization and it works.
Here is the code.
def get_calendar_limits(request):
result = serializers.serialize("json", Sessi...
Hi,
I am wondering if there are any django based, or even Python Based Reporting Services ala JasperReports or SQL Server Reporting Services?
Basically, I would love to be able to create reports, send them out as emails as CSV or HTML or PDF without having to code the reports. Even if I have to code the report I wouldn't mind, but the ...
How can I get the bounding box of a MultiPolygon object in geodjango? Can't find anything in the API http://geodjango.org/docs/geos.html ...
...
How secure are popular open source web frameworks?
I am particularly interested in popular frameworks like Rails and DJango.
If I am building a site which is going to do heavy e-commerce, is it Ok to use
frameworks like DJango and Satchmo?
Is security compromised because their open architecture ?
I know being OS does not mean being...
I have model for example like this:
class Meeting(models.Model):
date = models.DateTimeField(default=datetime.datetime.now)
team = models.CharField(max_length=100)
class Meta:
verbose_name_plural = u'Meetings'
ordering = ['-date', 'team']
def __unicode__(self):
return u'%s %s' % (self.date, self...
How do I get the choices field values and not the key from the form?
I have a form where I let the user select some user's emails for a company.
For example I have a form like this (this reason for model form is that it's inside a formset - but that is not important for now):
class Contacts(forms.ModelForm):
def __init__(self, *args...
A view I am using returns a string to a html template. The string which is returned contains special characters which are not represented correctly in the template. To put it simply a string which is returned from the view might look like this:
test = "\"Foo bar\""
return render_to_response('index.html', {'test': test})
And is displ...
I've got a variable number of items, somewhere between 0 and 20.
I'd like to list these with Google Static Maps, showing a little "a" for the first one, a "b" for the second one and so on.
I'm a newbie using Google App Engine so I'm constrained to 0.96 (unless I use various patches, which I don't want to do. Because I'm a newbie.)
&m...
Hello,
I have a datetime object at my model.
I am sending it to the view, but in html i don't know what to write in order to format it.
I am trying
{{ item.date.strftime("%Y-%m-%d")|escape }}
but I get
TemplateSyntaxError: Could not parse some characters: item.date.strftime|("%Y-%m-%d")||escape
when I am just using
{{ item.date...
I have a django model like this:
class Player(models.Model):
name = models.CharField()
batting = models.IntegerField()
bowling = models.IntegerField()
What would be the Django QuerySet equivalent of the following SQL?
SELECT * FROM player WHERE batting > bowling;
...