Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread greatlemer
> @G > > thanks for that. the code im writing will wait til dev version becomes > 1.2 so at least i know there is a way to do it in the next version. > must check when 1.2 is gonna land. You probably noticed anyway but ifchanged is actually in the current version (and has been since at least 1.0)

Re: how to display only one instance of an object returned by a query.

2010-04-26 Thread greatlemer
> finally when i write out the vehicles, i'd like to write a different > line for the first of each type of vehicle. to explain that, the > output should be an image linked to a fancybox gallery. because of the > amount of different vehicles, i'd like to only show one image of each > vehicle, but

Re: django signal and instace..... HELP!!

2010-04-20 Thread greatlemer
On Apr 20, 11:35 am, Allen Machary wrote: > Hellow.. > I have a problem on django signal and instances. > i have a right some code that runs a function after a certain model is > created but could not use the instace filter > > Help > > def send_sms_notifications(sender,

Re: Is the DoesNotExist exception the only way to check if an object exists?

2010-04-10 Thread greatlemer
This can work when you know you want to use the object once it's been retrieved. If all you want to do is check for existence then it's better to do the check with a: if Class.objects.filter(pk=pk).count() == 0: # Do object doesn't exist stuff else: # Do object does exist stuff -- G On

Re: How to concatenate a list of Q objects?

2010-04-08 Thread greatlemer
On Apr 7, 6:26 pm, Vinicius Mendes wrote: > On Wed, Apr 7, 2010 at 2:00 PM, Tom Evans wrote: > > On Wed, Apr 7, 2010 at 5:39 PM, Daniel wrote: > > > Hi, > > > > Thank you for your help everyone.  I know that I need to learn

Problem with cross-database foreign-keys and select_related

2010-03-26 Thread greatlemer
Hi, I'm running the django 1.2 beta and am testing out the multi-db system. Unfortunately I have run into an issue where I have: class A(models.Model): name = models.CharField() class B(models.Model): a = models.ForeignKey(A) I also have database routers set up so that A

Re: QuerySets - Reverse Look-Up for Index

2010-03-07 Thread greatlemer
if bids is ordered by index then you could just return BID.objects.filter(...).filter(pk__lte=id).count() and that should be what your after in one step (if I've understood the question correctly). -- G On Mar 7, 7:10 am, Hasan Karahan wrote: > Hi, > > I'm wondering

Re: Preventing "...and it's related items will be deleted" in Django Admin?

2010-02-16 Thread greatlemer
On Feb 16, 1:20 pm, Derek wrote: > Is there a secure method to override the facility for "and it's related > items will be deleted" for a specific model in the Django Admin? > > In some cases it is not appropriate that the "parent" model is deleted until > all the "child"

Re: Generic Relations and Django Admin?

2010-01-18 Thread greatlemer
On Jan 19, 5:25 am, Victor Hooi wrote: > heya, > > I'm trying to use an "Address" model as a generic relation against > multiple other models (e.g. in a "User Profile", for each User, as > well as for "Building", "Institution", and various other ones). > > So I've added the

Re: Help with a query :$

2010-01-05 Thread greatlemer
On Jan 5, 2:24 pm, Bill Freeman wrote: > On Mon, Jan 4, 2010 at 11:00 PM, Marc Aymerich wrote: > > class user(models.model): > > person = models.OneToOneField(person) > > I presume that you meant: > >           person = models.OneToOneField(employee) > >

Re: Help with a query :$

2010-01-04 Thread greatlemer
On Jan 5, 4:00 am, Marc Aymerich wrote: > Hi! > I have a model like this: > > class company(models.model): > name = models.CharField(mx_length=20) >  class employee(models.model): > comany = models.ForeignKey(company) >  class user(models.model): > person =

Re: Baseball statistics

2010-01-03 Thread greatlemer
On Jan 3, 2:36 pm, Tijmen wrote: > Hi there, > > First of all let me say I'm just starting here but need some help with > a rather basic question. > > I want to make an app that holds baseball statistics for players of > each game and over several seasons. Now I'm

Re: How to resolve the view name from a url

2009-11-24 Thread greatlemer
> > No, I don't. > > > I want to know the name of the url for a given url pattern. So, when I > > get in my method the url someone is asking for (next='/people/'), I > > want to know the name of the url that identifies this pattern > > (people_name). It's not for a HttpRedirect, it's for

Re: Models mixins/inheritance

2009-10-07 Thread greatlemer
What sort of errors are you getting when you try this with the django model? Have you tried just assigning the function over the top of the __unicode__ function already on Company? i.e. import Company def CompanyUnicode(self): return '%s [%s]' % (self.nick, self.legal_name)

Re: Overriding admin forms

2009-07-17 Thread greatlemer
On Jul 17, 3:06 pm, cornjuliox wrote: > Hi everyone. I'm new to Django, learning things mostly through trial > and error, but this time I can't seem to figure out what went wrong. I > overrode the admin change_form.html for my model so that I could add a > Javascript RTE

Re: Getting the name of a matched URL pattern

2009-07-02 Thread greatlemer
On Jul 1, 9:56 pm, Nick Fishman wrote: > Hey everyone, > > I'm working with Django's named URL patterns, and was wondering how to > fetch the name of the URL pattern that triggered the view. For > example, with the following urlpatterns > > urlpatterns = patterns('', >

Re: django-navbar

2009-06-19 Thread greatlemer
On Jun 18, 5:56 pm, Lars Stavholm wrote: > Has anyone been able to use django-navbar successfully > in latest Django 1.1 (from trunk)? > > Any ideas on how to use it appreciated. > > Or maybe there's a better navigation bar plugin? > > /Lars Stavholm I would say the

Re: Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer
On Jun 15, 10:47 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Mon, Jun 15, 2009 at 4:39 PM, greatlemer <greatle...@googlemail.com>wrote: > > > > > > > Hi everyone, > > > I was creating some custom template tags and attempted to import my >

Relative imports in custom template tag collections seem to look in the wrong place.

2009-06-15 Thread greatlemer
Hi everyone, I was creating some custom template tags and attempted to import my models through the following import at the top of the file: from ..models import * Unfortunately this seems to be attempting to import from django.models (which doesn't exist) rather than myapp.models and

Re: is it possible to have more than one search result in a view

2009-04-16 Thread greatlemer
Whoops, I think I hit the wrong reply option when I tried to post to this just now as it doesn't seem to have gone to the group. If what you're looking to do is to combine the results of both queries into one then what you probably want to use are the django Q objects to give something like