Re: Admin interface using my views

2008-07-08 Thread Stuart Grimshaw

On Jul 8, 2:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-08 at 06:22 -0700, Stuart Grimshaw wrote:
> > I'm getting this error when trying to view my admin interface ...
>
> > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > templates/admin/base.html, error at line 28
> > Caught an exception while rendering: Tried showSides in module
> > teamsheet.sheets.views. Error was: 'module' object has no attribute
> > 'showSides'
>
> As the error says, you are trying to use the "showSides" variable or
> function from some module, but it doesn't exist in that module. So
> search through your code for where you are calling showSides and find
> the case where it is being called incorrectly.

aha!

It was being called in one of my URL files, but the view is no longer
valid, or linked to so normal use of the site didn't trigger that
error.

Thanks Malcom.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Admin interface using my views

2008-07-08 Thread Stuart Grimshaw

I'm getting this error when trying to view my admin interface ...

In template /usr/lib/python2.5/site-packages/django/contrib/admin/
templates/admin/base.html, error at line 28
Caught an exception while rendering: Tried showSides in module
teamsheet.sheets.views. Error was: 'module' object has no attribute
'showSides'

"teamsheet.sheets.views" being my own views.

from settings.py:

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/Users/stuartgrimshaw/Project/teamsheet/templates'
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'teamsheet.sheets',
)

--~--~-~--~~~---~--~~
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: CharField as text?

2008-07-02 Thread Stuart Grimshaw

On Jul 1, 9:41 pm, Brian Luft <[EMAIL PROTECTED]> wrote:
> What is your purpose in defining a form field if it won't be used for
> user input?

I wanted to try and kee things simple (and look where that got me).

I have a list of players, and want to display them, with checkboxes
next to the names. I was following this example:

http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/

and could see a way to match the two lists in the view, so i moved all
the info I needed into the form class so I only needed 1 list of
objects.

-S
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CharField as text?

2008-07-01 Thread Stuart Grimshaw

Is it possible (with newforms) to either display a CharField as just
text, or have it's value used as the label on another field? I'm
displaying names against checkboxes and I want the names to appear as
the checkbox labels (or at least appear like they are)

Any tips anyone?

-S
--~--~-~--~~~---~--~~
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: Choosing between User.first_name/last_name & username

2008-06-22 Thread Stuart Grimshaw

On Jun 22, 11:48 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> Stuart Grimshaw wrote:
> > but it was throwing syntax errors on "player.player.first_name == '' ?
> > player.player.username : player.player.first_name)"
>
> It looks like you're trying to use a ternary operator here, but only
> Python 2.5 and later has one (and the syntax is different [2]). The

Thanks Nathaniel, I'm on 2.5, but was just using the wrong syntax ,,,

> good news is that you can accomplish what you want without using a
> ternary operator since Python boolean operators return values instead
> of just true or false [1]. Try the following instead::
>
>     swap_players_form.fields['side_a'].choices = [(
>             player.player.id,
>             player.player.first_name or player.player.username
>         ) for player in side_a]
>
> I similar idiom that I make frequent use of if I don't require that a
> user enter a first or last name and therefore need to use the username
> as a fallback is the following. (Note the built-in Django method
> ``get_full_name`` always returns a string, but the first name or the
> last name can be empty.)::

I was going for the full name, but using first_name as a starting
point, I figured if that was blank, they probably both were.

Thanks for pointing out get_full_name and for the introspection stuff
too, just what I needed.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Choosing between User.first_name/last_name & username

2008-06-22 Thread Stuart Grimshaw

As part of my sign up process, I don't require that people fill in
their first/last name, and just choose to show the username if no name
is entered.

Unfortunatly, I've come across a bit of code that I can't do this in,
which has got me thinking, I'm doing this all over the show, so there
must be a better way of doing it.

Ideally I'd like to just override the __unicode__ of the User method,
but I've been reading about the kerfuffle involved doing that, so does
anyone have any other bright ideas?

The problem that kicked all this off was that I was trying something
like this:

swap_players_form.fields['side_a'].choices = [(player.player.id,
player.player.first_name == '' ? player.player.username :
player.player.first_name) for player in side_a]

but it was throwing syntax errors on "player.player.first_name == '' ?
player.player.username : player.player.first_name)", if I could get
this method to work for now to let me move on that'd be a start.

Any ideas anyone?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---