Display ForeignKey label rather than ID in a CharField

2010-11-19 Thread Jamie Pittock
I have to override the default display of a foreignkey field in a form and instead display it as a CharField. Currently it displays the selection's ID but I need to display the label instead To be clear, the select option would be the default display for the ForeignKey. At the moment after I've

Re: View assistance

2009-11-25 Thread Jamie Pittock
Thanks again. On Nov 25, 4:00 pm, Javier Guerra wrote: > On Wed, Nov 25, 2009 at 10:42 AM, Jamie Pittock > wrote: > > Rolando, thanks.  Both your and Javier's solutions work.  Do they both > > do the same think in different ways?  Is one way better than the other >

Re: View assistance

2009-11-25 Thread Jamie Pittock
Rolando, thanks. Both your and Javier's solutions work. Do they both do the same think in different ways? Is one way better than the other in any way? On Nov 25, 3:40 pm, Jamie Pittock wrote: > Well that was ridiculously easy!  Thanks very much for responding > Javier. > > O

Re: View assistance

2009-11-25 Thread Jamie Pittock
Well that was ridiculously easy! Thanks very much for responding Javier. On Nov 25, 3:25 pm, Javier Guerra wrote: > On Wed, Nov 25, 2009 at 9:43 AM, Jamie Pittock > wrote: > > This is working as expected.  However, the view is checking that the > > project_slug is found,

View assistance

2009-11-25 Thread Jamie Pittock
I have two models, Project and Task. They are related via a foreign key in the task model. The view that displays a task is below... def task_detail(request, project_slug, task_id): project = get_object_or_404(Project, slug=project_slug) return object_detail(

Field value from queryset as extra_context

2009-05-10 Thread Jamie Pittock
Please excuse the subject if it makes no sense. Simplified, I have two models Pub and Town. Pub has a ForeignKey field called 'town'. I'm using the generic object_list view to display all pubs in a particular town (based on a town slug in the url). Something like this... def pubs_by_town(requ

Re: Wrapping object_detail generic view in another view

2009-05-09 Thread Jamie Pittock
Thanks George. On May 7, 9:32 pm, George Song wrote: > On 5/7/2009 1:01 PM, Jamie Pittock wrote: > > > Basically, am I doing things right, and if so which is the best > > solution from the above? > > Yup, you are doing things correctly as far as I can tell. > > A

Wrapping object_detail generic view in another view

2009-05-07 Thread Jamie Pittock
Hi all - As the subject suggests, I've wrapped the generic view date_based.object_detail in another view, and while my solution seem to be working, as I'm still new to Django, I'd like to check I'm doing things right with the experts (you!). I'm creating a blog that has multiple authors. The ur

Re: Count filtered by status

2009-03-21 Thread Jamie Pittock
Malcolm, thanks very much for this. I don't have time to properly look at this until Monday but I wanted to at least acknowledge before then my appreciation of your replies. I'll no doubt be back with either more thanks or more questions. On Mar 21, 4:55 am, Malcolm Tredinnick wrote: > On Sat

Count filtered by status

2009-03-20 Thread Jamie Pittock
Hi all, I have two models, Provider and Record. Record has the foreign key provider_id. In my template I'm displaying how many records a provider has by using object.record__set.count. If Record had a status field, how would I display how many records with a particular status a provider had?

Re: get_object_or_404 and foreignkey

2009-03-08 Thread Jamie Pittock
Thanks again. I'm still new to all this. On Mar 7, 9:37 pm, Daniel Roseman wrote: > On Mar 7, 8:21 pm, Jamie Pittock wrote: > > > Thanks Daniel.  Yeah it's just a way of getting the county so I'll try > > your second option.  Could you possibly point me to the

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Thanks Daniel. Yeah it's just a way of getting the county so I'll try your second option. Could you possibly point me to the docs that explain the double underscore? On Mar 7, 7:39 pm, Daniel Roseman wrote: > On Mar 7, 5:42 pm, Jamie Pittock wrote: > > > > > >

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Sorry, the correct url would be domain.com/country/county/ On Mar 7, 5:42 pm, Jamie Pittock wrote: > Hi, > > I have an app with countries and counties.  The simplified model is: > > class Country(models.Model): >         name = models.CharField(max_length=50) >         sl

get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Hi, I have an app with countries and counties. The simplified model is: class Country(models.Model): name = models.CharField(max_length=50) slug = models.SlugField() def __unicode__(self): return self.name class County(models.Model): name = mode

Re: Where to install additional libraries?

2008-06-23 Thread Jamie Pittock
ful with the specifics, but I do remember   > reading a lot of complaints on this issue so... be careful! > > Eric > > On Jun 23, 2008, at 10:10 PM, Jamie Pittock wrote: > > > > > Thank you Gordon (and Joshua) that's really useful. > > > I think I'll

Re: Where to install additional libraries?

2008-06-23 Thread Jamie Pittock
Thank you Gordon (and Joshua) that's really useful. I think I'll use the site-packages folder then. After doing what you said I've noticed I seem to have multiple installs of Python on my machine (OSX). /usr/lib/python2.5/ /Library/Python/2.5/ /opt/local/lib/python2.5/ /Library/Frameworks/Pytho

Where to install additional libraries?

2008-06-23 Thread Jamie Pittock
Hi all - this may well be a very basic question but I'm gonna ask it anyway as, everyone needs to learn, and I can't find the answer anywhere else. It's probably more related to Python than Django but... If you're installing additional Python libraries such as Imaging or Markdown, where are they

Tumblelog - Generic table or combine queries or...?

2008-02-17 Thread Jamie Pittock
Hi, I'm wanting to create a "tumblelog" of sorts made up of content from several different models within my site and I'm looking for suggestions on the best way of accomplishing it. The two ideas I have so far are: 1. Combine the results from different queries into one (as already discussed her

Adding own auth methods

2007-07-07 Thread Jamie Pittock
Hi all, I'm trying to figure out whether I can use Django's built in auth system for my needs. I need to limit access to certain areas depending on whether the user is member of particular groups. Not groups as in whether they area admins, moderators etc, but more in a social network type sense

Re: One-to-one relationship (model inheritance) or generic relations?

2007-06-29 Thread Jamie Pittock
9, 2:20 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 6/28/07, Jamie Pittock <[EMAIL PROTECTED]> wrote: > > > > > I don't want to code myself into a corner, so when I start looking at > > features such as allowing users to search all ven

One-to-one relationship (model inheritance) or generic relations?

2007-06-28 Thread Jamie Pittock
I'm still new to Django so bear with me ;) I have models for different types of venues (Bars, Clubs, etc). Because for example, I'd like to use one Rating model across all these venue Models I'd presumed that I'd need a parent Venue Model, using some kind of one-to-one relationship (until model i

Re: Subclasses or OneToOne relationship

2007-04-21 Thread Jamie Pittock
OK thanks very much for the reply Malcolm. On Apr 21, 3:47 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2007-04-20 at 20:00 +0000, Jamie Pittock wrote: > > Hi all, > > > I'm currently planning my first Django application and after a quick > &

Subclasses or OneToOne relationship

2007-04-20 Thread Jamie Pittock
Hi all, I'm currently planning my first Django application and after a quick search of groups I need a model structure very similar to that mention in this thread: http://groups.google.com/group/django-users/browse_thread/thread/48359c4c0faa797a Basically I need models for Restaurant, Bar, Hote

Re: Add to Favourites type feature?

2006-11-11 Thread Jamie Pittock
That's great. Thanks alot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EM

Re: Add to Favourites type feature?

2006-11-11 Thread Jamie Pittock
Sorry, I didn't mean add to your browser favourites. I meant more of a feature built into a website where users can mark an article/entry as a "favourite" to store or read later. that kind of thing. Russell Keith-Magee wrote: > On 11/10/06, Jamie Pittock <[EMAIL PROTECTED

Add to Favourites type feature?

2006-11-10 Thread Jamie Pittock
Morning all, I'm learning Django and Python as I go. A long shot but does anyone know of some site code that's been released with some kind of "add to favorites" feature? I know, it's cheating but I learn much quicker from examples. Or alternatively any relevant resources that might help? Any

Ordering by str

2006-11-10 Thread Jamie Pittock
I'm refering again to using this code from the cookbook: http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic My entry class has an 'assoc_cats' field (assoc_cats = models.ManyToManyField(Category)). How can I order the categories to match the __str__ (Home :: Garden) rather th

Re: Child Category Views

2006-11-09 Thread Jamie Pittock
Sorry, I missed those last two replies as I was replying myself. I'll take a look now and check I'm doing things right. Many thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post t

Re: Child Category Views

2006-11-09 Thread Jamie Pittock
great. I'm sure it's not perfect yet but I ended up with this: def entries_by_category(request, slug, childslug=None): if childslug is not None: slug = childslug category = get_object_or_404(Category, slug=slug) entry_list_by_category = category.entry_set.order_by('-pub_

Re: Child Category Views

2006-11-09 Thread Jamie Pittock
Sorry to reply to myself so quickly. After a bit of refactoring my two views look like this: def entries_by_category(request, slug): category = get_object_or_404(Category, slug=slug) entry_list_by_category = category.entry_set.order_by('-pub_date', 'title') return render

Child Category Views

2006-11-09 Thread Jamie Pittock
Hi folks, I've just started transporting an existing site to Django as a learning exercise and some quick help would be appreciated. I'm using some code from the cookbook to allow parent/child categories: http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic That's all dandy.