Hello,
I'd like to put this query from SQL to Django:
"select date_format(date, '%Y-%m') as month, sum(quantity) as hours from hourentries group by date_format(date, '%Y-%m') order by date;"
The part that causes problem is to group by month when aggregating. I tried this (which seemed logical), but it didn't work :
…
I'm working on a Django timesheet application and am having trouble figuring out how to include aggregate sums that equal zero. If I do something like:
entries = TimeEntry.objects.all().values("user__username").annotate(Sum("hours"))
I get all users that have time entries and their sums.
[{'username': u'bob'…
I am trying upload images and than create an thumbnail of it and than store both in S3. After the file has been uploaded i am first uploading it to S3 and than trying to create thumbnail but it doesn't work as than PIL is not able to recognise the image. And secondly if I create the thumbnail first than while…
I found a list of parameters that PayPal accepts, and I want to use a few additional ones other than what Django-PayPal recognizes. Is there an option for this?
Is it possible to have multiple models included in a single ModelForm in django? I am trying to create a profile edit form. So I need to include some fields from the User model and the UserProfile model. Currently I am using 2 forms like this
class UserEditForm(ModelForm):
class Meta:
model =…
Suppose, I want to record say poll choices by users everyday. In this case, i have a table named vote which has columns poll , choice and user-id . So how can i out the constraint (maybe in the django models or wherever possible) that poll and user-id both should not be the same for any entry but like the…
I have a model that looks like this:
class Client(models.Model):
name = models.CharField(max_length=100, primary_key=True)
user = models.ForeignKey(User)
class Contract(models.Model):
title = models.CharField(max_length=100, primary_key=True)
start_date =…
I have a custom tag in django, but i need use this functionality in a non-view, non-template stage without template engine, there is a way without repeat code?
I have a Django form that is working fine. I'd like to save the data it submits to a CSV file. Is there a "best practice" way to do this?
I need to include blank fields in the CSV file where the user has not filled in a "required=False" field
I have a form that looks like this:
class SampleForm(forms.Form):
text = forms.CharField(max_length=100)
In my django template, I want to reference the fact that the length is 100.
I tried
{{ form.text.max_length }}
to no avail.
On a related note, how do I reference this value…
Hello!
There's photologue application, simple photo gallery for django, implementing Photo and Gallery objects.
Gallery object has ManyToMany field, which references Photo objects.
I need to be able to get list of all Photos for a given Gallery. Is it possible to add Gallery filter to…
I have a model which is accessible through the Django admin area, something like the following:
# model
class Foo(models.Model):
field_a = models.CharField(max_length=100)
field_b = models.CharField(max_length=100)
# admin.py
class FooAdmin(admin.ModelAdmin):
pass
Let's…
I am making a multilingual Django website. I want the site to check from which country the user is accessing the website, and according to that decide which language to use.
What would be a good tool to use for that?
Does select_related work for GenericRelation relations, or is there a reasonable alternative? At the moment Django's doing individual sql calls for each item in my queryset, and I'd like to avoid that using something like select_related.
class Claim(models.Model):
proof =…
The following code snippet in a Django template (v 1.1) doesn't work.
{{ item.vendors.all.0 }} == returns "Test"
but the following code snippet, doesn't hide the paragraph!
{% ifnotequal item.vendors.all.0 "Test" %}
<p class="view_vendor">Vendor(s):…
Hi,
I am using the JQuery load function to load part of my page. Can I access the variables from that page in the page that loads it. e.g.
Page A uses JQuery load function to load B
Page B loads and sets a variable in context called pageB_var which…
Django-compress is great, but it doesn't offer any tags for compressing in-page javascript.
Are there some solutions out there? Even removing newlines (and adding ";" where needed) would be just great.
In my Django app, I just ran
$ python manage.py sqlall
and I see a lot of SQL statements that look like this, when describing FK relationships:
ALTER TABLE `app1_model1` ADD CONSTRAINT model2_id_refs_id_728de91f FOREIGN KEY (`model2_id`)…
I noticed in the main Django introductin they show a feature that maps python objects to the database. This doesn't strike me as being mutually exclusive with with development, is there any reason why this can't be used for non web apps? Is…
The Django documentation gives en example like so:
b = Blog.objects.get(id=1)
b.entry_set.all()
Which from what I understand results in 2 queries. What if I wanted to get the blog, the blog entries and all the comments associated with…
Hi All,
I am deploying a Django project on apache server with mod_python in linux. I have created a directory structure like:
/var/www/html/django/demoInstall where demoInstall is my project. In the httpd.conf I have put the following…
I am trying to test a googleapengine project locally, but am getting errors loading templates:
My settings.py contains TEMPLATE_LOADERS with Loader wrappers:
e.g. django.template.loaders.filesystem.Loader
but there is no Loader…
Hi,
I know python and have just read a basic intro of django. I have to built something like a travel website with real time updates. Will django be sufficent for this? Somebody advised me to look at django-CMS, I couldn't find a…
Hi expert there, this is my form:
class IPTrackerSearchForm(forms.Form):
keyword = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'size':'50'}))
search_in = forms.ChoiceField(required=False, choices=ANY_CHOICE +…