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 turned the display to a
CharField it displays 23 in the field.  I need to display Fish.

Fish

Any help appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: View assistance

2009-11-25 Thread Jamie Pittock
Thanks again.

On Nov 25, 4:00 pm, Javier Guerra <jav...@guerrag.com> wrote:
> On Wed, Nov 25, 2009 at 10:42 AM, Jamie Pittock <ja...@erskinedesign.com> 
> 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
> > in any way?
>
> i guess the generated SQL is the same.
>
> and as for better it's a matter of taste
>
> --
> Javier

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 <ja...@erskinedesign.com> wrote:
> Well that was ridiculously easy!  Thanks very much for responding
> Javier.
>
> On Nov 25, 3:25 pm, Javier Guerra <jav...@guerrag.com> wrote:
>
>
>
> > On Wed, Nov 25, 2009 at 9:43 AM, Jamie Pittock <ja...@erskinedesign.com> 
> > wrote:
> > > This is working as expected.  However, the view is checking that the
> > > project_slug is found, and also that the task_id is found, but it's
> > > not checking that the found task is related to the found project.
>
> > def task_detail(request, project_slug, task_id):
> >        project = get_object_or_404(Project, slug=project_slug)
> >        return object_detail(
> >                                request,
> >                                queryset=project.task_set,
> >                                object_id=task_id,
> >                                template_object_name="task",
> >                                extra_context = { 'project': project }
> >                                )
>
> > --
> > Javier

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 <jav...@guerrag.com> wrote:
> On Wed, Nov 25, 2009 at 9:43 AM, Jamie Pittock <ja...@erskinedesign.com> 
> wrote:
> > This is working as expected.  However, the view is checking that the
> > project_slug is found, and also that the task_id is found, but it's
> > not checking that the found task is related to the found project.
>
> def task_detail(request, project_slug, task_id):
>        project = get_object_or_404(Project, slug=project_slug)
>        return object_detail(
>                                request,
>                                queryset=project.task_set,
>                                object_id=task_id,
>                                template_object_name="task",
>                                extra_context = { 'project': project }
>                                )
>
> --
> Javier

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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(
request,
queryset=Task.objects.all(),
object_id=task_id,
template_object_name="task",
extra_context = { 'project': project }
)

The URL would look like this...

/projects/project_slug/tasks/task_id/

This is working as expected.  However, the view is checking that the
project_slug is found, and also that the task_id is found, but it's
not checking that the found task is related to the found project.

Could someone get me started on how best to write a view that would do
that?  I'm presuming I'd have to part company with generic views for
this?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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(request, town_slug):
town = get_object_or_404(Town, slug=town_slug)
return list_detail.object_list(
request,
queryset=Pub.objects.filter(town__slug=town_slug),
extra_context={ 'town': town },
template_name='pubs/pubs_by_town.html')

Pubs in {{ town.name }}

{% for pub in object_list %}
* {{ pub.name }}
{% endfor %}

This all works fine but getting the town object to use in the h1 seems
a bit redundant seeing as every pub instance in object_list will have
the same name of the town anyway.

Is it possible to use the queryset to pass the town name as
extra_context so that a variable is available to use in my template?
Is there a better way?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 <geo...@damacy.net> 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.
>
> As for creating a custom method or not, it's up to you, it's just a
> convenience wrapper, after all. I don't see much value in this specific
> instance, unless you think the meaning of "get_by_author" may change at
> some point.
>
> p.s. Use spaces instead of tabs in your code. It was extremely hard to read.
>
> --
> George
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 url for posts is
date based but also includes the author's username, like:

domain.com/username/blog/2009/may/02/blog-post/

The view I've created consists of the following...

def post_detail(request, username, year, month, day, slug):
return date_based.object_detail(request,
year,
month,
day,

Post.objects.filter(author__username__exact=username),

date_field='pub_date',

slug=slug,

slug_field='slug',

extra_context={},

template_name='blog/post_detail.html')

It seems to work but as I say I'm still new to Django and I'm not sure
if this the right way to go around it.

As an alternative I could create a method (get_by_author) in my
manager that does the filtering which I'd be able to reuse in the
object_list view, such as:

def post_detail(request, username, year, month, day, slug):
user = get_object_or_404(User, username__exact=username)
return date_based.object_detail(request,
year,
month,
day,

Post.objects.get_by_author(user.username),

date_field='pub_date',

slug=slug,

slug_field='slug',

extra_context={'user': user},

template_name='blog/post_detail.html')

Basically, am I doing things right, and if so which is the best
solution from the above?

Thanks in advance,
Jamie

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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, 2009-03-21 at 15:48 +1100, Malcolm Tredinnick wrote:
>
> [...]
>
> >         {% regroup status_counts by provider as s_counts %}
>
> >         {% for object in s_counts %}
> >            {% ifchanged object.provider %}
> >               {{ object.provider__name }}
> >               {{ object.provider__address }}
> >               {{ object.provider__rating }}
> >            {% endifchanged %}
> >            {{ object.status }}: {{ object. num }}
> >         {% endfor %}
>
> Aaargh! I changed my mind halfway through writing that solution and
> forgot to go back. I'm using the results of the regroup tag badly, so
> check the docs if you want to use that approach. My original approach
> was to order the queryset and then use "ifchanged" and then I realised
> the regroup tag solves that problem already.
>
> So, ignore the slight Frankenstein's monster result that came out. Think
> of it as two solutions for the price of one, but you have to untangle
> them in order to make either work.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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?

Many thanks in advance.
Jamie
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 <roseman.dan...@googlemail.com>
wrote:
> On Mar 7, 8:21 pm, Jamie Pittock <smallb...@gmail.com> 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 docs that
> > explain the double underscore?
>
> It's the standard syntax for lookups across relationships. 
> Seehttp://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-...
>
> --
> DR.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 <roseman.dan...@googlemail.com>
wrote:
> On Mar 7, 5:42 pm, Jamie Pittock <smallb...@gmail.com> wrote:
>
>
>
>
>
> > 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 = models.CharField(max_length=50)
> >         slug = models.SlugField()
> >         country = models.ForeignKey(Country)
>
> >         def __unicode__(self):
> >                 return self.name
>
> > The url for a county would be of the format domain.com/country/
> > country/.
>
> > On the corresponding view for that url I'm currently doing this...
>
> > def view_county(request, country_slug, county_slug):
> >         country = get_object_or_404(Country, slug=country_slug)
> >         county = get_object_or_404(County, slug=county_slug,
> > country=country.id)
>
> > 1. First checking to see if a country exists with that slug
> > 2. Then checking to see if a county exists with that slug and also
> > with the country_id of the country found in step #1
>
> > Can that be merged into one step, or is there a better way completely
> > of doing it?
>
> It depends - do you actually need the 'country' object in the rest of
> your view, or are you simply using it as a way to get the county? If
> the latter, you could just do:
> county = get_object_or_404(Country, slug=county_slug,
>         country__slug=country_slug)
> Note the double underscore in the country__slug argument.
>
> --
> DR.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 <smallb...@gmail.com> wrote:
> 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 = models.CharField(max_length=50)
>         slug = models.SlugField()
>         country = models.ForeignKey(Country)
>
>         def __unicode__(self):
>                 return self.name
>
> The url for a county would be of the format domain.com/country/
> country/.
>
> On the corresponding view for that url I'm currently doing this...
>
> def view_county(request, country_slug, county_slug):
>         country = get_object_or_404(Country, slug=country_slug)
>         county = get_object_or_404(County, slug=county_slug,
> country=country.id)
>
> 1. First checking to see if a country exists with that slug
> 2. Then checking to see if a county exists with that slug and also
> with the country_id of the country found in step #1
>
> Can that be merged into one step, or is there a better way completely
> of doing it?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 = models.CharField(max_length=50)
slug = models.SlugField()
country = models.ForeignKey(Country)

def __unicode__(self):
return self.name

The url for a county would be of the format domain.com/country/
country/.

On the corresponding view for that url I'm currently doing this...

def view_county(request, country_slug, county_slug):
country = get_object_or_404(Country, slug=country_slug)
county = get_object_or_404(County, slug=county_slug,
country=country.id)

1. First checking to see if a country exists with that slug
2. Then checking to see if a county exists with that slug and also
with the country_id of the country found in step #1

Can that be merged into one step, or is there a better way completely
of doing it?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Where to install additional libraries?

2008-06-23 Thread Jamie Pittock

No, that does help.  This is all making sense now.  Looking around in
the different site-packages folders I can start seeing where things
have gone wrong.   I was running 'sudo python setup.py install' but it
didn't appear to be doing anything.  It turns out they were just being
installed in a different location.

Based on what I've gleaned from this thread I've changed my PYTHONPATH
to use /Library/Python/2.5/site-packages and my PATH now uses /System/
Library/.../2.5/

Anyway, thanks very much everyone.


On Jun 23, 3:23 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> It may very well make a difference if you're using python2.4 and you  
> install packages in a python2.5 site-packages directory! I remember  
> reading somewhere that that was one of the issues of doing a Leopard  
> upgrade, versus wiping the drive and doing a full install. I did the  
> latter, and I don't have python2.4 anymore, and all my packages go in  
> a single convenience directory: /Library/Python/2.5/site-packages,  
> though the python installation itself is still under /Library/
> Frameworks.
>
> Sorry I can't be more helpful 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 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/Python.framework/Versions/2.4/lib/python2.4/
> > (currently being used)
>
> > This is probably due in part to upgrading to Leopard and it changing
> > the location, maybe?
>
> > I presume again it doesn't matter which of these I use aslong as I'm
> > consistent?
>
> > On Jun 23, 2:23 pm, gordyt <[EMAIL PROTECTED]> wrote:
> >> Jamie the command you quoted "python setup.py install" -- on my  
> >> system
> >> I have to run it as root or else do "sudo python setup.py install" --
> >> will copy the files for that module to the appropriate location.
>
> >> If the module you are interested in is in pure Python, with no c-
> >> code,
> >> you can often just make it available anywhere on your PYTHONPATH.
>
> >> In any event, the most common place that extra stuff gets installed  
> >> is
> >> in your "site-packages" folder.  On my Ubuntu machine that is located
> >> in two places:
>
> >> /usr/lib/python2.5/site-packages
> >> /usr/local/lib/python2.5/site-packages
>
> >> You can always find the location on your system by asking Python
> >> itself:
>
> >>>>> import sys
> >>>>> for p in sys.path:
>
> >> ...  print p
> >> ...
>
> >> /usr/lib/python2.5/site-packages
> >> /usr/lib/python2.5/site-packages/lxml-2.1beta2-py2.5-linux-x86_64.egg
> >> /usr/lib/python25.zip
> >> /usr/lib/python2.5
> >> /usr/lib/python2.5/plat-linux2
> >> /usr/lib/python2.5/lib-tk
> >> /usr/lib/python2.5/lib-dynload
> >> /usr/local/lib/python2.5/site-packages
> >> /usr/lib/python2.5/site-packages
> >> /usr/lib/python2.5/site-packages/Numeric
> >> /usr/lib/python2.5/site-packages/PIL
> >> /usr/lib/python2.5/site-packages/gst-0.10
> >> /var/lib/python-support/python2.5
> >> /usr/lib/python2.5/site-packages/gtk-2.0
> >> /var/lib/python-support/python2.5/gtk-2.0
>
> >> Here is an example of what I mentioned earlier about installing pure
> >> Python modules... I have both django and report lab checked out of  
> >> the
> >> repository and just put symbolic links to them in the /usr/local/lib/
> >> python2.5/site-packages folder:
>
> >> [EMAIL PROTECTED]:/usr/local/lib/python2.5/site-packages$ pwd
> >> /usr/local/lib/python2.5/site-packages
> >> [EMAIL PROTECTED]:/usr/local/lib/python2.5/site-packages$ ls -l
> >> total 12
> >> lrwxrwxrwx  1 root staff   34 2007-12-28 10:29 django -> /home/gordy/
> >> projects/python/django
> >> -rw-r--r--  1 root staff  548 2008-02-05 14:14 moin-1.6.1.egg-info
> >> -rw-r--r--  1 root staff  548 2008-02-05 13:38 moin-1.6.1-py2.5.egg-
> >> info
> >> drwxr-sr-x 25 root staff 4096 2008-02-05 13:38 MoinMoin
> >> lrwxrwxrwx  1 root staff   37 2008-01-15 10:41 reportlab -> /home/
> >> gordy/projects/python/reportlab
>
> >> Works great.
>
> >> --gordon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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/Python.framework/Versions/2.4/lib/python2.4/
(currently being used)

This is probably due in part to upgrading to Leopard and it changing
the location, maybe?

I presume again it doesn't matter which of these I use aslong as I'm
consistent?


On Jun 23, 2:23 pm, gordyt <[EMAIL PROTECTED]> wrote:
> Jamie the command you quoted "python setup.py install" -- on my system
> I have to run it as root or else do "sudo python setup.py install" --
> will copy the files for that module to the appropriate location.
>
> If the module you are interested in is in pure Python, with no c-code,
> you can often just make it available anywhere on your PYTHONPATH.
>
> In any event, the most common place that extra stuff gets installed is
> in your "site-packages" folder.  On my Ubuntu machine that is located
> in two places:
>
> /usr/lib/python2.5/site-packages
> /usr/local/lib/python2.5/site-packages
>
> You can always find the location on your system by asking Python
> itself:
>
> >>> import sys
> >>> for p in sys.path:
>
> ...  print p
> ...
>
> /usr/lib/python2.5/site-packages
> /usr/lib/python2.5/site-packages/lxml-2.1beta2-py2.5-linux-x86_64.egg
> /usr/lib/python25.zip
> /usr/lib/python2.5
> /usr/lib/python2.5/plat-linux2
> /usr/lib/python2.5/lib-tk
> /usr/lib/python2.5/lib-dynload
> /usr/local/lib/python2.5/site-packages
> /usr/lib/python2.5/site-packages
> /usr/lib/python2.5/site-packages/Numeric
> /usr/lib/python2.5/site-packages/PIL
> /usr/lib/python2.5/site-packages/gst-0.10
> /var/lib/python-support/python2.5
> /usr/lib/python2.5/site-packages/gtk-2.0
> /var/lib/python-support/python2.5/gtk-2.0
>
> Here is an example of what I mentioned earlier about installing pure
> Python modules... I have both django and report lab checked out of the
> repository and just put symbolic links to them in the /usr/local/lib/
> python2.5/site-packages folder:
>
> [EMAIL PROTECTED]:/usr/local/lib/python2.5/site-packages$ pwd
> /usr/local/lib/python2.5/site-packages
> [EMAIL PROTECTED]:/usr/local/lib/python2.5/site-packages$ ls -l
> total 12
> lrwxrwxrwx  1 root staff   34 2007-12-28 10:29 django -> /home/gordy/
> projects/python/django
> -rw-r--r--  1 root staff  548 2008-02-05 14:14 moin-1.6.1.egg-info
> -rw-r--r--  1 root staff  548 2008-02-05 13:38 moin-1.6.1-py2.5.egg-
> info
> drwxr-sr-x 25 root staff 4096 2008-02-05 13:38 MoinMoin
> lrwxrwxrwx  1 root staff   37 2008-01-15 10:41 reportlab -> /home/
> gordy/projects/python/reportlab
>
> Works great.
>
> --gordon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 supposed to go?  Installation instructions
always say download the the files and run 'python setup.py install'
but they never state where to put the files.

Is there a specific place they need to go...or if not specific, is
there a conventional place?

Thanks in advance.
Jamie
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 here -
http://groups.google.com/group/django-users/browse_frm/thread/4a37a6b2cf6b34d6/d23994d6c6765170?lnk=gst=sorting=4#d23994d6c6765170)

2. Use the contenttypes framework and create a generic TumblelogItem
Model that would hold the content_type and ids of all the model items
I'd like to "tumble".  Something like...

class TumbleLogItem(models.Model):
author = models.ForeignKey(User)
pub_date = models.DateTimeField()
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = models.GenericForeignKey()

Does anyone have any advice on the use of either of these two
options?  Or is there a better third way?

Thanks.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 of the word groups.

How would I go about adding my own methods, something like:

request.user.is_member_of(group)

?

I'm sure I'll need to change the name 'groups' so that it doesn't
clash with the built-in stuff, but hopefully you can understand what I
mean.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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

2007-06-29 Thread Jamie Pittock

Russ,

Really useful response, thanks.

I had thought about your third option but as I figured there'd be a
lot of empty fields I didn't give it much consideration.  I might
actually go down that route until I have a better understanding of
generic relations.

Thanks again.
j.

On Jun 29, 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 venues would I be best
> > with one parent model or will I be ok keeping them separate?   The
> > different types of venues have quite a number of different attributes
> > btw which is why they are different models rather than simply
> > categoried.
>
> Model inheritance sounds good on paper, but in practice, it gets
> somewhat inconvenient - lots of table joins to get at basic
> attributes, etc. If you have very few common attributes anyway,
> generic relations are probably worth investigation.
>
> However, as always, YMMV. My only reservation in recommending generic
> relations is that they aren't fully integrated with admin yet (though
> there is a patch floating around to integrate them with
> newforms-admin), and they're not fully documented. However, if you're
> willing to put up with those limitations, it sounds like they could be
> a good match for your needs.
>
> A third approach that you haven't mentioned is to have a single
> 'object' table that is sparse; i.e., instead of
>
> class Bar(Model):
>name = CharField()
>number_of_bartenders = IntegerField()
>
> class Club(Model):
>name = CharField()
>music_style = CharField()
>
> you have a single model that has all the fields:
>
> class Venue(Model):
>name = CharField()
>venuetype = CharField(choices=(('b','bar'),('c','club'))
>number_of_bartenders = IntegerField(null=True)
>music_style = CharField(null=True)
>
> This way you spend a little more time in data validation (making sure
> that you have all the columns that you need for any given row), and
> you waste a little space in the database, but lookups will be a little
> faster (as no joins are required).
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 inheritance is
reintroduced), so that each venue had a unique primary key that could
be related to the rating.

However, apps such as comment and tagging get away with it.  Is this
through Generic Relations?

I don't want to code myself into a corner, so when I start looking at
features such as allowing users to search all venues would I be best
with one parent model or will I be ok keeping them separate?   The
different types of venues have quite a number of different attributes
btw which is why they are different models rather than simply
categoried.

Any clarification much appeciated.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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
> > 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/4835...
>
> > Basically I need models for Restaurant, Bar, Hotel etc but it would be
> > useful to have a parent model Place that could contain the fields
> > general to all the models, plus it would be useful so that a
> > restuarant and bar wouldn't have the same ID, or at least they'd have
> > a unique Place ID.
>
> > Has Model Inheritance moved on at all since that previous thread?
>
> Not yet.
>
> >  Is
> > a OnetoOneField the best option,
>
> Yes.
>
> >  or ,given that (after another quick
> > search) it seems Model Inheritance may well be back in the not too
> > distant future,
>
> Correct.
>
> >  is there another option that would make an easy
> > transition once it is supported?
>
> Use one-to-one now and change it to MI later. The changes won't be that
> significant. A few quick search-and-replace operations in your templates
> and views should do it.
>
> Cheers,
> Malcolm


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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, Hotel etc but it would be
useful to have a parent model Place that could contain the fields
general to all the models, plus it would be useful so that a
restuarant and bar wouldn't have the same ID, or at least they'd have
a unique Place ID.

Has Model Inheritance moved on at all since that previous thread?  Is
a OnetoOneField the best option, or ,given that (after another quick
search) it seems Model Inheritance may well be back in the not too
distant future, is there another option that would make an easy
transition once it is supported?

Any advice much appreciated.

Jamie


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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]> wrote:
> >
> > 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.
>
> This isn't a feature that is (or should be) part of Django or Python -
> it's a Javascript method that manipulates the window object. Put the
> relevant javascript in your page template, and Django will serve a
> page with that functionality.
>
> > Or alternatively any relevant resources that might help?
>
> In this case - Google.
>
> More broadly - the Rhino book (Javascript complete reference from
> O'Reilly) is pretty much as good as it gets for Javascript references.
> 
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 help appreciated.

Jamie


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 than just their name (Garden)?


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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 to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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_date',
'title')
return render_to_response('cake/entries_by_category.html',
{'entry_list_by_category': entry_list_by_category, 'category':
category})


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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_to_response('cake/entries_by_category.html',
{'entry_list_by_category': entry_list_by_category, 'category':
category})

def entries_by_child_category(request, slug, childslug):

category = get_object_or_404(Category, slug=childslug)
entry_list_by_category = category.entry_set.order_by('-pub_date',
'title')
return render_to_response('cake/entries_by_category.html',
{'entry_list_by_category': entry_list_by_category, 'category':
category})

With the urlpatterns:

(r'^category/(?P[-\w]+)/(?P[-\w]+)',
'entries_by_child_category'),
(r'^category/(?P[-\w]+)', 'entries_by_category'),

I'm sure there must be a way of doing this with just the one view
though.


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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.  What I'm struggling with is the views listing
entries by category.

At the moment I have one view for the parent category and then another
if a child category is in the url.

This is the view I'm using if there's just one category.

def entries_by_category(request, slug):

category = Category.objects.get(slug=slug)
entry_list = category.entry_set.order_by('-pub_date', 'title')

t = loader.get_template('cake/entries_by_category.html')
c = Context({
'object_list': entry_list,
'category_name': category,
})

return HttpResponse(t.render(c))

And then as I say, if there's also a child category in the url I'm
basically replicating that view with

def entries_by_child_category(request, slug, childslug):

I'm sure there's a much better way of doing this using just one view.
Can anyone give me a pointer?

Jamie


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---