Re: Is it essential to run setup.py?

2007-05-22 Thread Thomas Ashelford



On May 23, 3:16 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> In order for Python to be able to use some bit of code -- in this
> case, Django -- that bit of code has to be in a directory that's on
> the "Python path"; that's a list of directories Python looks into
> whenever you have an 'import' statement. The job of setup.py is to
> automatically place a new Python-based application on the Python path
> so that Python can import code from it, though this is really provided
> as a convenience.
James, thanks for the succinct explanation. That confirms what I
thought (in a slightly uncertain way) was happening.

> The "manual" option is to either copy the "django" directory
> containing all of Django's code into a directory that's on the Python
> path, or to edit the Python path to include the directory Django is
> in. Editing the Python path varies across operating systems, so you
> may want to simply copy Django over to somewhere on the path.
I have actually edited my Python path already  - that's how I got the
development version working - so perhaps there's something else not
right? In any case, moving 0.96 onto the Python path is not really an
option for me, as I already have a working copy of 0.95 sitting there.
I was actually trying to set up an alternate instance of Django so I
could test its compatibility with my code, before upgrading the copy
of Django that runs behind my main server. I don't want the
embarrassment of upgrading and ending up with a broken site. The fact
that I can get the dev version working in the alternate directory, but
not the 0.96 version makes me worry that it's something more than just
the Python path.

By the way, my site *does* break under the dev version - I have a
couple of FloatFields in there - but as soon as I changed them it
worked fine. So what started as a cautious test of my code's
compatibility with the latest version of Django, has now made me worry
about my ability to install an official Django release! Previously
I've worked with either dev releases (using svn), or pre-installed
official releases (on WebFaction), so I haven't had to face this
before.

Thomas


--~--~-~--~~~---~--~~
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: Displaying my table data

2007-05-22 Thread Greg

Yea, I'm not sure why I used choice as the field name.  I probably
should of used style.  Anyway, here are all my models

class Size(models.Model):
name = models.CharField(maxlength=100)

def __str__(self,):
return self.name

class Admin:
pass

class Price(models.Model):
name = models.IntegerField()

def __str__(self,):
return str(self.name)

class Admin:
pass

class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))


class Admin:
search_fields = ['name']


def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
num_in_admin=5)
size = models.ForeignKey(Size, core=True)
price = models.ForeignKey(Price, core=True)

def __str__(self,):
return str(self.choice)


Again my problem is i want to know how to view all the sizes and
prices for a paticular rug.  In my python shell I do the following.
I currently have 3 sizes and prices
associated with style 89b, but I can't seem to figure out how to
access them.  a.size, a[size], etc



>>> a = Choice.objects.filter(choice=1)
>>> a


[, , ]


Thanks for any help


On May 22, 11:06 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> What does the model code look like for Size,Price?
>
> Also,
>
> choice = models.ForeignKey(Style,
> edit_inline=models.TABULAR,num_in_admin=5)
>
> Did you mean for that to be:
>
> style = models.ForeignKey(Style,
> edit_inline=models.TABULAR,num_in_admin=5)
>
> Just curious..as then it would be consistent with the other objects.
>
> On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
> > Vance,
> > Ok...that worked.  However, I have a new problem.  I'm not sure how to
> > display all the sizes and colors of a particular rug.  In my shell
> > python I do the following
>
> > >>> a = Choice.objects.filter(choice=1)
> > >>> a
>
> > [, , ]
>
> > What do I need to type into the shell prompt to get all the sizes and
> > colors associated with style 89b.  I currently have 3 sizes and colors
> > associated with style 89b, but I can't seem to figure out how to
> > access them.  a.size, a[size], etc
>
> > Here are my model files.
>
> > class Style(models.Model):
> > name = models.CharField(maxlength=200)
> > theslug = models.SlugField(prepopulate_from=('name',))
>
> > class Admin:
> > search_fields = ['name']
>
> > def __str__(self,):
> > return self.name
>
> > class Choice(models.Model):
> > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > num_in_admin=5)
> > size = models.ForeignKey(Size, core=True)
> > price = models.ForeignKey(Price, core=True)
>
> > def __str__(self,):
> > return str(self.choice)
>
> > Thanks
>
> > On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > > My bet would be that this little bit of code right here:
>
> > > def __str__(self,):
> > >return self.choice
>
> > > the return of __str__ needs to be a string not an object.
>
> > > Vance
>
> > > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > I am trying to display the table in my Choice table.  However it's
> > > > error's out everytime I try to see the contents of the table.
>
> > > > In my python shell prompt I do the following and get the error
>
> > > > C:\django\mysite>python manage.py shell
> > > > (InteractiveConsole)
> > > > >>> from mysite.rugs.models import Choice
> > > > >>> c = Choice.objects.all()
> > > > >>> c
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in ?
> > > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > > 102, in _
> > > > _repr__
> > > > return repr(self._get_data())
> > > >   File "c:\Python24\lib\site-packages\django\db\models\base.py", line
> > > > 86, in __r
> > > > epr__
> > > > return '<%s: %s>' % (self.__class__.__name__, self)
> > > > TypeError: __str__ returned non-string (type Style)
>
> > > > Here are my choice models file
>
> > > > class Choice(models.Model):
> > > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > > num_in_admin=5)
> > > > size = models.ForeignKey(Size, core=True)
> > > > price = models.ForeignKey(Price, core=True)
>
> > > > def __str__(self,):
> > > > return self.choice
>
> > > > Does anybody know why I can't display the data in the table?
>
> > > --
> > > To pretend, I actually do the thing: I have therefore only pretended to 
> > > pretend.
> > >   - Jacques Derrida- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


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

Re: Serialization with file output

2007-05-22 Thread Ramashish Baranwal

Malcolm Tredinnick wrote:
> > I am trying to serialize some model data with the output going to a
> > file. I am doing it the way its suggested in the documentation.
> >
> > XMLSerializer = serializers.get_serializer("xml")
> > xml_serializer = XMLSerializer()
> > out = open("file.xml", "w")
> > xml_serializer.serialize(SomeModel.objects.all(), stream=out)
> >
> > This throws an AttributeError-
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> > base.py", line 50, in serialize
> > return self.getvalue()
> >   File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> > base.py", line 110, in getvalue
> > return self.stream.getvalue()
> > AttributeError: 'file' object has no attribute 'getvalue'
> >
> > Looking into base.py, I found that the serialize function attempts to
> > return the entire data using getvalue function of the stream it wrote
> > to. That works for StringIO which is used if one doesn't pass a
> > stream, but not for a file object.
> >
> > This doesn't look like an intentional behavior. Am I missing
> > something?
>
> This was bug #3435, fixed in [5075]. Since we only fixed it a month ago
> (April 25), the fix isn't in 0.95 or 0.96. However, you could look at
> that changeset and manually patch your local copy yourself if you wanted
> to.

Thanks Malcolm.

Regards,
Ramashish


--~--~-~--~~~---~--~~
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: Is it essential to run setup.py?

2007-05-22 Thread James Bennett

On 5/23/07, Thomas Ashelford <[EMAIL PROTECTED]> wrote:
> I'm hoping that setup.py is just a convenience file that does
> something I can do manually (I'm a python newbie, so when I took a
> look inside I was a bit bamboozled. I could probably figure it out
> given a spare hour or two!)

In order for Python to be able to use some bit of code -- in this
case, Django -- that bit of code has to be in a directory that's on
the "Python path"; that's a list of directories Python looks into
whenever you have an 'import' statement. The job of setup.py is to
automatically place a new Python-based application on the Python path
so that Python can import code from it, though this is really provided
as a convenience.

The "manual" option is to either copy the "django" directory
containing all of Django's code into a directory that's on the Python
path, or to edit the Python path to include the directory Django is
in. Editing the Python path varies across operating systems, so you
may want to simply copy Django over to somewhere on the path.

To find out which directories are on your Python path (and, therefore,
where you could put Django so Python can find it), do the following in
a Python interpreter:

>>> import sys
>>> print sys.path

This will list all the locations currently on your Python path.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Is it essential to run setup.py?

2007-05-22 Thread Thomas Ashelford

I'm trying to install an instance of Django version 0.96 on a server
where I don't have root access. I'm unable run setup.py using sudo as
described in the documentation, and when I leave out that step I get
"ImportError: No module named django". The development version works
fine, so I'm assuming that setup.py must do something essential.

I'm hoping that setup.py is just a convenience file that does
something I can do manually (I'm a python newbie, so when I took a
look inside I was a bit bamboozled. I could probably figure it out
given a spare hour or two!)

Is there any kind soul who could explain what I can do to install 0.96
without root access?

Cheers
Thomas


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



{{ perms }} seems to be empty

2007-05-22 Thread Michael Lake

Hi all

I have a template and request is being passed to it and so I expected that
{{ perms }} would be availablke as in Chap 12 of the Django book.

I have this:

Permissions:
{% for permission in in request.user.get_all_permissions %}
+ {{ permission }}
{% endfor %}

{% if perms.lab %}
yes you have permissions
{% else %}
no permissions
{% endif %}

On output I get:

Permissions:
   + lab.change_test
   + lab.delete_test
   + lab.add_test
no permissions


I get the same "no permissions" if I try {% if perms.lab %} or {% if perms %}

What am I doing wrong?

Mike

-- 
Michael Lake




--~--~-~--~~~---~--~~
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: manipulator.do_html2python(new_data) not working?

2007-05-22 Thread [EMAIL PROTECTED]

Can you post your manipulator code?

On May 18, 1:35 pm, Mason <[EMAIL PROTECTED]> wrote:
> I'm a Newbie at Django (release ver. 0.96) and I've got a problem with
> saving data from a Django checkbox to MySQL.
>
> The code that I'm running looks like this:
>
> manipulator.do_html2python(new_data)
> print "\nnew data: ", new_data
> new_baseline_fsr = manipulator.save(new_data)
>
> The print statement shows that new_data is providing [True] or [False]
> values for the boolean fields which are appearing as check boxes, but
> the error message from the web server is reporting either empty
> strings or 'on' values as follows:
>
> OperationalError at /fsr/create_new/140101,13-1001/
> (1366, "Incorrect integer value: 'on' for column 'coldwork' at row 1")
> Request Method: POST
> Request URL:http://127.0.0.1:8000/fsr/create_new/140101,13-1001/
> Exception Type: OperationalError
> Exception Value:(1366, "Incorrect integer value: 'on' for column
> 'coldwork' at row 1")
> Exception Location: C:\Python24\lib\site-packages\MySQLdb
> \connections.py in defaulterrorhandler, line 35
>
> Does anyone out there have any ideas about what I'm doing wrong?


--~--~-~--~~~---~--~~
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: A bizarre Forms-via-Templates idea...

2007-05-22 Thread Doug B

The dev server operates much differently than an actual production
server.  The production server will only evaluate module code once
when the module is initially loaded.  It doesn't automatically scan
for file changes and load files as necessary like the dev server
does.  If you want file changes to be reflected, you need to restart
your server (or change some apache settings I think).

This actually works to your advantage if you put your forms in a file
that's loaded as a module rather than in say a view function.  If you
have a forms.py file with your forms they will only be evaluated once
when forms.py file is first loaded.

so

Form = forms_for_model()

actually creates form once, and not every request or every time you
instantiate a form.  This also makes dynamic choices a bit tough to
deal with, but that is another issue!

You still have form instantiation to be done any time you use the
form, but unless you want to give up most of the goodies newforms
offers I don't see a way around that.  I have a feeling the overhead
of form creation is really pretty small compared to other factors.

On the other hand, if you need to render the same blank form page to a
bunch of requests, you could render the entire page and cache it using
one of Django's cache backends and do something similar to what you
suggest.


--~--~-~--~~~---~--~~
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: Displaying my table data

2007-05-22 Thread [EMAIL PROTECTED]

What does the model code look like for Size,Price?

Also,

choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)

Did you mean for that to be:

style = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)

Just curious..as then it would be consistent with the other objects.

On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
> Vance,
> Ok...that worked.  However, I have a new problem.  I'm not sure how to
> display all the sizes and colors of a particular rug.  In my shell
> python I do the following
>
> >>> a = Choice.objects.filter(choice=1)
> >>> a
>
> [, , ]
>
>
>
> What do I need to type into the shell prompt to get all the sizes and
> colors associated with style 89b.  I currently have 3 sizes and colors
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc
>
> Here are my model files.
>
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> theslug = models.SlugField(prepopulate_from=('name',))
>
> class Admin:
> search_fields = ['name']
>
> def __str__(self,):
> return self.name
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return str(self.choice)
>
> Thanks
>
> On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > My bet would be that this little bit of code right here:
>
> > def __str__(self,):
> >return self.choice
>
> > the return of __str__ needs to be a string not an object.
>
> > Vance
>
> > On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> > > I am trying to display the table in my Choice table.  However it's
> > > error's out everytime I try to see the contents of the table.
>
> > > In my python shell prompt I do the following and get the error
>
> > > C:\django\mysite>python manage.py shell
> > > (InteractiveConsole)
> > > >>> from mysite.rugs.models import Choice
> > > >>> c = Choice.objects.all()
> > > >>> c
> > > Traceback (most recent call last):
> > >   File "", line 1, in ?
> > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > 102, in _
> > > _repr__
> > > return repr(self._get_data())
> > >   File "c:\Python24\lib\site-packages\django\db\models\base.py", line
> > > 86, in __r
> > > epr__
> > > return '<%s: %s>' % (self.__class__.__name__, self)
> > > TypeError: __str__ returned non-string (type Style)
>
> > > Here are my choice models file
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
>
> > > def __str__(self,):
> > > return self.choice
>
> > > Does anybody know why I can't display the data in the table?
>
> > --
> > To pretend, I actually do the thing: I have therefore only pretended to 
> > pretend.
> >   - Jacques Derrida- Hide quoted text -
>
> > - Show quoted text -


--~--~-~--~~~---~--~~
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: Serialization with file output

2007-05-22 Thread Malcolm Tredinnick

On Wed, 2007-05-23 at 03:51 +, Ramashish Baranwal wrote:
> Hi,
> 
> I am trying to serialize some model data with the output going to a
> file. I am doing it the way its suggested in the documentation.
> 
> XMLSerializer = serializers.get_serializer("xml")
> xml_serializer = XMLSerializer()
> out = open("file.xml", "w")
> xml_serializer.serialize(SomeModel.objects.all(), stream=out)
> 
> This throws an AttributeError-
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> base.py", line 50, in serialize
> return self.getvalue()
>   File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> base.py", line 110, in getvalue
> return self.stream.getvalue()
> AttributeError: 'file' object has no attribute 'getvalue'
> 
> Looking into base.py, I found that the serialize function attempts to
> return the entire data using getvalue function of the stream it wrote
> to. That works for StringIO which is used if one doesn't pass a
> stream, but not for a file object.
> 
> This doesn't look like an intentional behavior. Am I missing
> something?

This was bug #3435, fixed in [5075]. Since we only fixed it a month ago
(April 25), the fix isn't in 0.95 or 0.96. However, you could look at
that changeset and manually patch your local copy yourself if you wanted
to.

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



Re: WANTED: Demonstration of good FK & M2M form creation

2007-05-22 Thread [EMAIL PROTECTED]

You could do this pretty easily using your own forms ( not NewForms
and not Add/Change Manipulators ) along with the Django DB objects.

It's pretty easy to do a CustomChangeManipulator with fields from two
tables if it's just a one to one relationship, but for M2M, I usually
either roll my own or I display a list of the rentals with an 'edit'
link next to each item in the list.

On May 20, 2:19 pm, David Priest <[EMAIL PROTECTED]> wrote:
> I believe I have performed exhaustive research on the challenge of
> creating forms that incorporate fields from multiple tables.  I have
> not found *any* comprehensive, best-practices examples of this problem.
>
> It really quite surprises me, as any web application of even moderate
> complexity requires multiple tables.
>
> Anyway, I think everyone (and especially all us n00bs) would *really*
> appreciate a good bit of demonstration code for the following sort of
> scenario:
>
> class Customer(models.Model):
> name = models.CharField()
> phone = models.PhoneNumber()
>
> class Rentals(models.Model):
> title = models.CharField()
> serial = models.Integer()
> rented_to = models.ForeignKey(Customer)
> rental_due = models.DateField()
>
> The Form should display the customer's name, phone number, and the
> movies the customer has rented, but *not* the date they're due
> ('cause I'd like this problem to represent real-world problems, where
> one doesn't necessarily display all the fields for editing).
>
> I've been battling at this for days, reading a lot of newsposts and
> websites, and I've come up with bupkiss.  It is extraordinarily
> frustrating.


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



Serialization with file output

2007-05-22 Thread Ramashish Baranwal

Hi,

I am trying to serialize some model data with the output going to a
file. I am doing it the way its suggested in the documentation.

XMLSerializer = serializers.get_serializer("xml")
xml_serializer = XMLSerializer()
out = open("file.xml", "w")
xml_serializer.serialize(SomeModel.objects.all(), stream=out)

This throws an AttributeError-
Traceback (most recent call last):
  File "", line 1, in ?
  File "/home/ram/jasmine/Django-0.95/django/core/serializers/
base.py", line 50, in serialize
return self.getvalue()
  File "/home/ram/jasmine/Django-0.95/django/core/serializers/
base.py", line 110, in getvalue
return self.stream.getvalue()
AttributeError: 'file' object has no attribute 'getvalue'

Looking into base.py, I found that the serialize function attempts to
return the entire data using getvalue function of the stream it wrote
to. That works for StringIO which is used if one doesn't pass a
stream, but not for a file object.

This doesn't look like an intentional behavior. Am I missing
something?

Thanks,
Ram


--~--~-~--~~~---~--~~
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: select_related() and child rows

2007-05-22 Thread hartshorne

I think it's reasonable for Django to leave this one up to the
framework user. Thanks!

Beau

On May 21, 10:12 pm, simonbun <[EMAIL PROTECTED]> wrote:
> As far as i know, select_related doesn't work across reverse
> relationships. Sometimes it's possible to just query the base model to
> achieve the same results, but not always.
>
> Maybe its a good feature for the query.py rewrite, but i'm thinking it
> could get ugly pretty fast. It would require a new parameter to
> specify which reverse relationships you want to cover, seeing as a
> mere select_related could give you a 20+ table join, 5+ second
> query :-)
>
> regards,
> Simon
>
> On May 21, 8:49 pm,BeauHartshorne <[EMAIL PROTECTED]> wrote:
>
> > I've got some models that look something like this:
>
> > class Entry(models.Model):
> >text = models.TextField()
>
> > class SubEntry(models.Model):
> >text = models.TextField()
> >sub_entry = models.ForeignKey(Entry)
>
> > class SubSubEntry(models.Model):
> >text = models.TextField()
> >sub_sub_entry = models.ForeignKey(SubEntry)
>
> > So SubSubEntry.objects.select_related().all() gets the data from
> > SubEntry and Entry with one query.
>
> > SubEntry.objects.select_related().all() gets the data from Entry with
> > one query, but not from SubSubEntry. What's the best way to work
> > around this? Or am I doing something wrong?
>
> > Thanks,
> >Beau


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



A bizarre Forms-via-Templates idea...

2007-05-22 Thread David Priest

Templates can output any textfile we care, right?  And django's got  
this nifty auto-updating thing going, where changes to a file are  
immediately reloaded into the running application.  So...

We use forms_for_model to get the fields, put it into a request  
context, and call a template which outputs a valid Python program  
containing class myname(forms.Form) definitions.  These, in turn, are  
used to render UI forms for the end-user.

It'd require a few django hooks, so as to execute after a models.py  
file is changed; and to render without needing an http request.

Alternatively, I might be crazy to think this is feasible.

--~--~-~--~~~---~--~~
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: Komodo and Django - code completion / code intellisensing

2007-05-22 Thread ro



On May 11, 1:59 am, oliver <[EMAIL PROTECTED]> wrote:
> Thanks, for both comments but still no luck.
> I tried multiple various but it still gives me the same error.
>
> my projects are in c:\django-projects\Project1..
>
> I installed the latest beta ofkomodo, but has the same thing.
> Python2.5 is installed in c:/python25 and is in my path (from the CMD
> i can start pyton any where)
>
> any other suggestions?
>
> thanks again for helping
>
> oli
>
> On May 10, 3:12 pm, Ceph <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > Go to Edit > Preferences. Expand the "Languages" group by clicking the
> > [+] symbol. Click "Python". Click the little "Add..." button under
> > "Additional Python Import Directories". Add the directory ABOVE your
> > project and you should have intellisense enabled.
>
> > On May 9, 12:01 pm, oliver <[EMAIL PROTECTED]> wrote:
>
> > > Hi i am evaluatingkomodoas my django/python ide but i can't get the
> > > code completion to work. It gives me this error:
>
> > > error evaluating 'models' at models.py#4: NameError: global name 'XXX'
> > > is not defined (C:\Prog..\Active..\lib\mozilla\python\komodo
> > > \codintel2\tree_python.py#169 in _members_from_elem) (error
> > > determining completions)
>
> > > I am on Windows XP, python 2.5,komodoide 4.0, latest django svn.
> > > This error appears when you type for example:
>
> > > class ...
> > >   name = models.
>
> > > right after the models "."
>
> > > any one got this to work or is this a general bug inkomodo?
>
> > > Thanks!- Hide quoted text -
>
> - Show quoted text -

I have the same problem with you.
I think it is a bug of komodo


--~--~-~--~~~---~--~~
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: "showable" but not "editable" field in the Admin screens

2007-05-22 Thread Brian Rosner

You may also want to check out http://code.djangoproject.com/ticket/3990.

On May 22, 5:19 am, "Seiji - technics" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Is there a way to show as specific field in the admin screens but
> without permitting to edit it?
> I want something similar to "editable=False" option but without
> excluding the field from the screen.
>
> Thanks in advance for the help.
>
> Seiji


--~--~-~--~~~---~--~~
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: Offline Django Apps

2007-05-22 Thread Robert Coup

Rob Hudson wrote:
> Cool.  What's the best way to coordinate the effort?  A wiki page to
> start with?
>   
Current trends seem to be to use Google Code for projects that aren't 
likely to become part of the core django distro. A link from the Django 
wiki is probably a good idea though.
> 1) Cross Platform Libraries...
>
> In looking at DjangoKit a little I see he's using PyObjC.  I do like
> the idea of using whatever the native widget library is for each
> platform.  I'll have to look at the Democracy Player as an example but
> they did something similar (Mac: PyObjC, Linux: PyGTK, Windows: ???).
>   
wxWidgets is one cross-platform option. PyGTK runs on windows too.
> 2) Database...
>
> It makes sense to me to require SQLite for this to work.  Moving your
> data to SQLite is also a requirement for Slingshot.  I'm pretty sure
> we can use the fixtures library to serialize data from databases other
> than SQLite (MySQL, PostGreSQL), then load it up into SQLite.
>   
Yeah, that's perfectly reasonable IMHO.

Rob :)

--~--~-~--~~~---~--~~
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: WANTED: Demonstration of good FK & M2M form creation

2007-05-22 Thread Malcolm Tredinnick

On Tue, 2007-05-22 at 17:23 -0700, David Priest wrote:
> On 07-May-21, at 5:56 PM, Malcolm Tredinnick wrote:
> > It sounds like you want the django.newforms.formsets capability that
> > isn't on trunk yet.
> 
> >
> > A little more patience will be required.
> 
> Is this patience measured in days and short weeks, or in long weeks  
> turning to months?  I need to decide whether I do it all by hand  
> right-this-moment, or delay until I can use the new newforms  
> capabilities...

I have no real idea, although I'd lean towards the shorter periods. The
real answer is that there's no real promise we can make here. We're all
volunteers and most of us have lives of some extent or another.

If you really wanted to do something now, grab formsets.py from the
newforms-admin branch and start playing with (and extending, if
necessary) that. Then when it is merged into trunk, you'll already have
a start, even if you have to customise your code.

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



Re: WANTED: Demonstration of good FK & M2M form creation

2007-05-22 Thread David Priest

On 07-May-21, at 5:56 PM, Malcolm Tredinnick wrote:
> It sounds like you want the django.newforms.formsets capability that
> isn't on trunk yet.

>
> A little more patience will be required.

Is this patience measured in days and short weeks, or in long weeks  
turning to months?  I need to decide whether I do it all by hand  
right-this-moment, or delay until I can use the new newforms  
capabilities...

I'm loving where Django is heading.  :-)


--~--~-~--~~~---~--~~
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: Offline Django Apps

2007-05-22 Thread Rob Hudson

Cool.  What's the best way to coordinate the effort?  A wiki page to
start with?

Coming up in the next month or so I'm going to have to dedicate work
time to this but for now I'd like to just lay out the groundwork and
do it in such a way that it benefits the Django community.

1) Cross Platform Libraries...

In looking at DjangoKit a little I see he's using PyObjC.  I do like
the idea of using whatever the native widget library is for each
platform.  I'll have to look at the Democracy Player as an example but
they did something similar (Mac: PyObjC, Linux: PyGTK, Windows: ???).

2) Database...

It makes sense to me to require SQLite for this to work.  Moving your
data to SQLite is also a requirement for Slingshot.  I'm pretty sure
we can use the fixtures library to serialize data from databases other
than SQLite (MySQL, PostGreSQL), then load it up into SQLite.

3) Anything else?

Thanks,
Rob


--~--~-~--~~~---~--~~
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: Another problem with django-multilingual

2007-05-22 Thread Eugene Morozov

Hello,
Thank you for fixing the bug so quickly. But if you'll add
'i18n.multilingual' to the list of installed apps in the settings.py
in the example I've attached to #22, then "manage.py runserver" or
"manage.py syncdb" commands stop working with exception
"AttributeError: 'module' object has no attribute 'multilingual'"
Eugene

On 23 май, 00:06, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi Eugene,
>
> On May 22, 5:44 pm, Eugene Morozov <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to use django-multilingual for multilingual site, instead
> > of reinventing the wheel. But in admin interface I get:
> > "Something's wrong with your database installation. Make sure the
> > appropriate database tables have been created, and make sure the
> > database is readable by the appropriate user." for every translatable
> > model.
>
> A knee-jerk question here is: did you remember to run syncdb after
> creating the translatable models?  If you did, try again and make sure
> there were no validation errors.
>
> > slug = models.SlugField(prepopulate_from=("name",))
>
> The prepopulate_from parameter contains a nonexistant field name (you
> probably wanted to use "title" instead), but apparently Django does
> not validate it.  I just pasted your Entry model into one of apps in
> my testproject, added missing models (Author, Blog and Picture) and it
> simply worked for me.
>
> If syncdb does not help, then please try to create a minimal test app
> for the problem and post it to django-multilingual bug tracker (http://
> code.google.com/p/django-multilingual/).
>
> -mk


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



Breaking CAPTCHAs Without Using OCR

2007-05-22 Thread Moona Naeem
Breaking CAPTCHAs Without Using OCR

This article details a method I have discovered to bypass CAPTCHA
security, without having to use Optical Character Recognition software.

http://2site.com/ibfaem


Is Mark Warren's Ultimate Wealth Package Worth the Money?


You could go take a college course in marketing or entrepreneurship at
your local university or community college and spend thousands of
dollars. I took a course called Principles of Marketing.

http://2site.com/cnrqev


"Legitimate" Online Paid Survey Scams Revealed Part 1


Are you looking for scam-free and legitimate online paid surveys, free
membership online paid survey, fact honest paid survey or market online
paid research survey?

http://2site.com/hqmdca


--~--~-~--~~~---~--~~
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: How to define unsigned integer primary keys with auto increment for MySQL

2007-05-22 Thread Malcolm Tredinnick

On Tue, 2007-05-22 at 06:43 -0700, Fay wrote:
> I'm using MySQL. The primary key field generated by django uses
> integer, not unsigned. I'd like to us unsigned integer instead. I can
> explicitly specify PositiveIntegerField with primary_key option, but
> that doesn't seem to give me auto increment. Any ideas? Thanks.

Write the necessary SQL to alter the table after it's created and put it
in the "initial SQL" file for that model. See the model-api docs for
more information on initial SQL.

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



Re: "showable" but not "editable" field in the Admin screens

2007-05-22 Thread Malcolm Tredinnick

On Tue, 2007-05-22 at 08:19 -0300, Seiji - technics wrote:
> Hi all,
> 
>  
> 
> Is there a way to show as specific field in the admin screens but
> without permitting to edit it?
> 
> I want something similar to “editable=False” option but without
> excluding the field from the screen.

Once newforms-admin lands, we'll probably alter things so that you can
put non-editable fields in the fields list. That will do exactly what
you're after.

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



Re: decimal fields + json serializing [was Re: Decimal fields have landed on trunk: rename your FloatFields]

2007-05-22 Thread Malcolm Tredinnick

On Tue, 2007-05-22 at 18:13 +0200, Bram - Smartelectronix wrote:
> Hey,
> 
> Malcolm Tredinnick wrote:
> 
> > It works with Python 2.3 as well and I've tested it with every database
> > I have access to on 2.3, 2.4 and 2.5. So hopefully the only bugs should
> > be easy to fix things in edge cases.
> 
> Eek, I might have found one:
> 
> TypeError at /my/url/
> Decimal("0.0") is not JSON serializable

Pleasee file a ticket with a small, self-contained, repeatable example
that demonstrates the problem. Reporting ticket son the mailing list is
a good way to have them forgotten about.

I did test JSON serialisation of decimals, so it doesn't fail always.
There's a change in core/serializers/json.py for exactly that purpose.
So there's something special about your setup.

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



Re: Another problem with django-multilingual

2007-05-22 Thread [EMAIL PROTECTED]

Due to some weirdness on google groups I did not see your second
message when replying to the first one.  The SQL you posted was enough
to solve the problem.

On May 22, 9:28 pm, Eugene Morozov <[EMAIL PROTECTED]> wrote:
> In addition to this issue, I'm getting SQL errors on attempts to 
> savemultilingualobjects, because of such invalid constructs:

It is the same issue: django-multilingual constructs incorrect table
names for language codes that contain a dash.

I just committed a fix for that.

> Aliases must be quoted by django, but they aren't. I've tried to find
> what causes this quoting error but gave up after two hours... Need to
> get some sleep.

They are not because this part of SQL is generated by D-M, not Django
core, in multilingual/query.py.  I should probably fix it soon.

Thanks for trying out D-M and submitting the bug report,
-mk


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



Sitemaps and large sites

2007-05-22 Thread John DeRosa

I've implemented sitemaps for my site (www.trenchmice.com), and I've run
into a problem because of my site's size.

TrenchMice has 275K pages, generated from 275K+ database objects. The 
sitemap classes return information on every object, which means they try 
to return information on 275K+ objects! And as a result, the sitemap.xml 
lookup never finishes.  (I gave up after waiting an hour...)

The sitemap classes dutifully return infrequently updated objects with a
low priority and frequency.  But because the classes look up 275K+
objects, and return _all_ the items in each set, it never finishes.

Unless I'm missing something obvious (and I might be), a straightforward
implementation of the sitemaps protocol doesn't work for large sites.

What do large sites do?  Do they return only the most recent N objects 
of every class?  If so, then how do the search engines find out about 
the infrequently updated objects?

John


--~--~-~--~~~---~--~~
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: Another problem with django-multilingual

2007-05-22 Thread [EMAIL PROTECTED]

Hi Eugene,

On May 22, 5:44 pm, Eugene Morozov <[EMAIL PROTECTED]> wrote:
> I'm trying to use django-multilingual for multilingual site, instead
> of reinventing the wheel. But in admin interface I get:
> "Something's wrong with your database installation. Make sure the
> appropriate database tables have been created, and make sure the
> database is readable by the appropriate user." for every translatable
> model.

A knee-jerk question here is: did you remember to run syncdb after
creating the translatable models?  If you did, try again and make sure
there were no validation errors.

> slug = models.SlugField(prepopulate_from=("name",))

The prepopulate_from parameter contains a nonexistant field name (you
probably wanted to use "title" instead), but apparently Django does
not validate it.  I just pasted your Entry model into one of apps in
my testproject, added missing models (Author, Blog and Picture) and it
simply worked for me.

If syncdb does not help, then please try to create a minimal test app
for the problem and post it to django-multilingual bug tracker (http://
code.google.com/p/django-multilingual/).

-mk


--~--~-~--~~~---~--~~
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: Another problem with django-multilingual

2007-05-22 Thread Eugene Morozov

In addition to this issue, I'm getting SQL errors on attempts to save
multilingual objects, because of such invalid constructs:
  LEFT JOIN blog_blogtranslation AS blog_blogtranslation_zh-cn ON
((blog_blogtranslation_zh-cn.master_id = blog_blog.id) AND
(blog_blogtranslation_zh-cn.language_id = 38))

Aliases must be quoted by django, but they aren't. I've tried to find
what causes this quoting error but gave up after two hours... Need to
get some sleep.

Did anyone attempted to use django-multilingual?
Eugene


On 22 май, 19:44, Eugene Morozov <[EMAIL PROTECTED]> wrote:
> Hello,
> I'm trying to use django-multilingual for multilingual site, instead
> of reinventing the wheel. But in admin interface I get:
> "Something's wrong with your database installation. Make sure the
> appropriate database tables have been created, and make sure the
> database is readable by the appropriate user." for every translatable
> model. For example, I have a model for blog entry:
>
> class Entry(models.Model):
> author = models.ForeignKey(Author, related_name="entries")
> blog = models.ForeignKey(Blog, related_name="entries")
> pictures = models.ManyToManyField(Picture, blank=True,
>   related_name="entries")
> comments_allowed = models.BooleanField(_("Comments allowed"))
> posted = models.DateTimeField(_("Date posted"), auto_now_add=True)
>
> class Translation(multilingual.Translation):
> title = models.CharField(_("Title"), maxlength=250,
>  help_text=_("Title of the entry"))
> slug = models.SlugField(prepopulate_from=("name",))
> body = models.TextField(_("Body"))
>
> As you see, it has both translatable and non-translatable fields. I'm
> running Django-0.96 on python2.5. I use psycopg2 db adapter.
> Eugene


--~--~-~--~~~---~--~~
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: Offline Django Apps

2007-05-22 Thread James Bennett

On 5/22/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
> I'm curious if there are others who could use this functionality but
> for Django.  If so, perhaps we can all collaborate and come up with a
> solution that runs on Mac, Windows, and Linux.  Data syncing would be
> nice but can come later.

I'd be interested, certainly. Not sure I have much to contribute in
the way of desktop programming skills, but I can think of more than a
couple uses for such a thing and I'll happily do whatever I can.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Offline Django Apps

2007-05-22 Thread Rob Hudson

I have a need for a way to run Django-based websites offline as an
installable application.  I recently read about Joyent Slingshot:
http://developer.joyent.com/

I'm curious if there are others who could use this functionality but
for Django.  If so, perhaps we can all collaborate and come up with a
solution that runs on Mac, Windows, and Linux.  Data syncing would be
nice but can come later.

A big bootstrap and proof of concept is most definitely DjangoKit:
http://jerakeen.org/blog/2007/04/djangokit-gets-better/

Thanks,
Rob


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



Sitemaps and large sites

2007-05-22 Thread John DeRosa

I've implemented sitemaps for my site (www.trenchmice.com), and I've run 
into a problem because of my site's size.

TrenchMice has 275K pages, generated from 275K+ database objects. (These 
are "topics" and "scoops".) The sitemap classes return information on 
every object, which means try to return information on 275K+ objects! 
And as a result, the sitemap.xml lookup never finishes.  (I gave up 
after waiting an hour...)

The sitemap classes dutifully return infrequently updated objects with a 
low priority and frequency.  But because the classes look up 275K+ 
objects, returning _all_ the items in each set, etc., it never finishes.

Unless I'm missing something obvious (and I might be), a straightforward 
implementation of the sitemaps protocol won't work for large sites.

So, what do large sites do?  Do they return only the most recent N 
objects of every class?  If so, then how do the search engines find out 
about the infrequently updated objects?

John


--~--~-~--~~~---~--~~
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: Displaying my table data

2007-05-22 Thread Greg

Vance,
Ok...that worked.  However, I have a new problem.  I'm not sure how to
display all the sizes and colors of a particular rug.  In my shell
python I do the following

>>> a = Choice.objects.filter(choice=1)
>>> a
[, , ]
>>>

What do I need to type into the shell prompt to get all the sizes and
colors associated with style 89b.  I currently have 3 sizes and colors
associated with style 89b, but I can't seem to figure out how to
access them.  a.size, a[size], etc

Here are my model files.


class Style(models.Model):
name = models.CharField(maxlength=200)
theslug = models.SlugField(prepopulate_from=('name',))


class Admin:
search_fields = ['name']


def __str__(self,):
return self.name

class Choice(models.Model):
choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
num_in_admin=5)
size = models.ForeignKey(Size, core=True)
price = models.ForeignKey(Price, core=True)

def __str__(self,):
return str(self.choice)


Thanks









On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
> My bet would be that this little bit of code right here:
>
> def __str__(self,):
>return self.choice
>
> the return of __str__ needs to be a string not an object.
>
> Vance
>
> On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > I am trying to display the table in my Choice table.  However it's
> > error's out everytime I try to see the contents of the table.
>
> > In my python shell prompt I do the following and get the error
>
> > C:\django\mysite>python manage.py shell
> > (InteractiveConsole)
> > >>> from mysite.rugs.models import Choice
> > >>> c = Choice.objects.all()
> > >>> c
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > 102, in _
> > _repr__
> > return repr(self._get_data())
> >   File "c:\Python24\lib\site-packages\django\db\models\base.py", line
> > 86, in __r
> > epr__
> > return '<%s: %s>' % (self.__class__.__name__, self)
> > TypeError: __str__ returned non-string (type Style)
>
> > Here are my choice models file
>
> > class Choice(models.Model):
> > choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > num_in_admin=5)
> > size = models.ForeignKey(Size, core=True)
> > price = models.ForeignKey(Price, core=True)
>
> > def __str__(self,):
> > return self.choice
>
> > Does anybody know why I can't display the data in the table?
>
> --
> To pretend, I actually do the thing: I have therefore only pretended to 
> pretend.
>   - Jacques Derrida- Hide quoted text -
>
> - Show quoted text -


--~--~-~--~~~---~--~~
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: trouble using fastcgi

2007-05-22 Thread Mark Phillips

Thanks to all who responded.


On May 20, 2007, at 8:11 AM, jordi.f wrote:

> Any reason for not using Django's built-in fastcgi server?

I did try that. In the end, I built up another server based on Centos  
and used mod-python. I plan to revisit the fastcgi approach when I  
have more time to rebuild the os x server.

Happy days,

  - Mark


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



Another problem with django-multilingual

2007-05-22 Thread Eugene Morozov

Hello,
I'm trying to use django-multilingual for multilingual site, instead
of reinventing the wheel. But in admin interface I get:
"Something's wrong with your database installation. Make sure the
appropriate database tables have been created, and make sure the
database is readable by the appropriate user." for every translatable
model. For example, I have a model for blog entry:

class Entry(models.Model):
author = models.ForeignKey(Author, related_name="entries")
blog = models.ForeignKey(Blog, related_name="entries")
pictures = models.ManyToManyField(Picture, blank=True,
  related_name="entries")
comments_allowed = models.BooleanField(_("Comments allowed"))
posted = models.DateTimeField(_("Date posted"), auto_now_add=True)

class Translation(multilingual.Translation):
title = models.CharField(_("Title"), maxlength=250,
 help_text=_("Title of the entry"))
slug = models.SlugField(prepopulate_from=("name",))
body = models.TextField(_("Body"))

As you see, it has both translatable and non-translatable fields. I'm
running Django-0.96 on python2.5. I use psycopg2 db adapter.
Eugene


--~--~-~--~~~---~--~~
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: Django-tagging app not showing up in admin

2007-05-22 Thread [EMAIL PROTECTED]

I've solved the issue. It seems it was a combination of my the tagging
app not being on my PYTHONPATH, and some database issues.

Everything seems to work correctly now.

On May 21, 10:49 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I'm building a blog using Django, and am wanting to usedjango-tagging
> for, well, tagging.
>
> But something isn't working right. And I haven't a clue why (yes, I'm
> a beginner).
>
> I've added the tagging app to my INSTALLED_APPS in the settings.py
> file. It is located inside my project, which is also where my blog app
> is located.
>
> Funny thing is, it seems to work using the Django dev server (tags,
> etc show up in admin, and I can add tags to a blog entry). It's only
> when I try and deploy this to my prod server that my blog app and the
> tagging app fail to display in the admin.
>
> Also, when I move the tagging app outside of my project, both the blog
> app and tagging app show up in the admin in my prod environment. But I
> get a Django error when I try to save an entry from my blog app
> (presumably because of the location of the tagging app).
>
> The blog app was working before I installed the tagging app (showed up
> in admin).
>
> What am I doing wrong?
>
> Here is my blog app models.py file:
>
> from django.db import models
> from django.contrib.auth.models import User
> from tagging.fields import TagField
>
> PUBLICATION_CHOICES = (
> ('Draft', 'Draft'),
> ('Published', 'Published'),
> )
>
> class Entry(models.Model):
> # Basic blog fields
> pub_date = models.DateTimeField()
> author = models.ForeignKey(User)
> headline = models.CharField(maxlength=200)
> slug = models.SlugField(prepopulate_from=('headline',),
> unique_for_date='pub_date')
> summary = models.TextField(help_text="Use raw XHTML.")
> body = models.TextField(help_text="Use raw XHTML.")
> tags = TagField()
> # Extra fields
> pull_quote = models.TextField(blank=True)
> centerpiece_art = models.ImageField(upload_to='images/centerpiece-
> art/', blank=True, help_text="Should be XXXpx wide.")
> # Misc
> enable_comments = models.BooleanField(default=True)
> publication = models.CharField(maxlength=32,
> choices=PUBLICATION_CHOICES, radio_admin=True, default='Published')
>
> class Meta:
> db_table = 'blog_entries'
> verbose_name_plural = 'entries'
> ordering = ('-pub_date',)
> get_latest_by = 'pub_date'
>
> class Admin:
> list_display = ('pub_date', 'headline', 'slug')
>
> def __str__(self):
> return self.headline
>
> def get_absolute_url(self):
> return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%b/
> %d").lower(), self.slug)
>
> def get_comment_count(self):
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.comments.models import Comment
> ctype = ContentType.objects.get(name__exact='entry')
> num_comments = Comment.objects.filter(content_type=ctype.id,
> object_id=self.id).count()
> return num_comments


--~--~-~--~~~---~--~~
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: Best-practices for form with image

2007-05-22 Thread Sam

Your request is called a "captcha"

You can find examples in the groups or there :

http://code.google.com/p/django-captcha/
http://www.djangosnippets.org/tags/captcha/


On 22 mai, 09:59, Xin Xic <[EMAIL PROTECTED]> wrote:
> Hello,
>
> First, sorry for my english.
>
> Well, I want out a form for a human verification with an image and an
> input field. But I don't know how is the best practice for make this.
> How do you do it?
>
> I need print:
>   - An image (different in each case)
>   - An hidden input with data relationated with the image.
>   - An input field for write de response.
>
> I have thank 3 options:
>1.- Create a extended hidden widget for print the image.
>2.- Create a multi-field that verify itself image, hidden and
> response fields
>3.- Print the image within a form function with hidden and input
> fields, and verify data in form
>4.- Option 3 but verify data out of form.
>
> What do you think?
> Thanks
>
> Salut i força al canut,


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



Categorization of Two Models

2007-05-22 Thread Brian Rosner

I am looking for some advise on how to go about creating something with 
Django.  Any help would be greatly appreciated!

I am created a website that will need to support two different, yet 
similar models at the same level.  So I have a legacy product model 
called XCProduct and a new product model called Product.  These in 
theory are the same thing and for the most part contain the same data, 
but is different enough that required two different models.  I would 
like to seemlessly make these two models appear as one.  They will have 
different display requirements, but that can be handled in their apps.  
Basically I will need a Category model to glue these together, but at 
the same time of thinking about this I'd like to see my Category model 
to be generic enough to really just be a hierarchy of pages that get 
displayed differently.  Does anyone have advice on how to implement 
this?   I first thought about using generic relations, but not 100% 
sure on how to go about it.

-- 
Brian Rosner
http://www.brosner.com/blog



--~--~-~--~~~---~--~~
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: unit tests: database confusion

2007-05-22 Thread Russell Keith-Magee

On 5/22/07, jararaca <[EMAIL PROTECTED]> wrote:
>
> A short while ago I had my unit tests up and running, including
> reading some objects from a fixture. Today I've tried to run the tests
> again (calling 'manage.py test' just as I did before). Now the test
> database is created as I can see using the MySQL Frontend, but the
> objects from the fixture never show up there - in spite of the command
> line output telling me they have been installed. Furthermore I get
> lots of errors like "Failed to install index for ... 'Duplicate key
> name...'".

The only cause I can think of for this level of confusion would be a
stray settings file somewhere. The settings file is just another
python file; if there are multiple settings.py files on your
PYTHONPATH, you could get data put into unexpected databases, etc.

> But the strangest part is yet to come: When testing, it is obviously
> always my "real" database that is being read, not the 'test_xy'
> database, even if I change DATABASE_NAME in settings!

I have no idea why it would write to the real database, unless your
stray settings file contained a TEST_DATABASE_NAME value that was the
same as your DATABASE_NAME.

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



How to define unsigned integer primary keys with auto increment for MySQL

2007-05-22 Thread Fay

I'm using MySQL. The primary key field generated by django uses
integer, not unsigned. I'd like to us unsigned integer instead. I can
explicitly specify PositiveIntegerField with primary_key option, but
that doesn't seem to give me auto increment. Any ideas? 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: Best-practices for form with image

2007-05-22 Thread [EMAIL PROTECTED]

And there are no best practices for using something as inherently
inaccessible and annoying as a captcha.

On May 22, 7:16 am, Sam <[EMAIL PROTECTED]> wrote:
> Your request is called a "captcha"
>
> You can find examples in the groups or there :
>
> http://code.google.com/p/django-captcha/http://www.djangosnippets.org/tags/captcha/
>
> On 22 mai, 09:59, Xin Xic <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > First, sorry for my english.
>
> > Well, I want out a form for a human verification with an image and an
> > input field. But I don't know how is the best practice for make this.
> > How do you do it?
>
> > I need print:
> >   - An image (different in each case)
> >   - An hidden input with data relationated with the image.
> >   - An input field for write de response.
>
> > I have thank 3 options:
> >1.- Create a extended hidden widget for print the image.
> >2.- Create a multi-field that verify itself image, hidden and
> > response fields
> >3.- Print the image within a form function with hidden and input
> > fields, and verify data in form
> >4.- Option 3 but verify data out of form.
>
> > What do you think?
> > Thanks
>
> > Salut i força al canut,


--~--~-~--~~~---~--~~
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: Apache configuration

2007-05-22 Thread Daniel Ellison

On Monday 21 May 2007 14:27:02 dystopia wrote:
> I'm worried that I haven't set this up properly, because in effect the
> application (which is for test purposes) should really run off the
> main domain rather than requiring to be accessed through a folder.

Alternatively, you could set up a temporary subdomain for the project. Many 
hosts allow a certain number of these domains for an account. This would 
allow you to use the subdomain's root instead of a folder, avoiding the need 
to change everything when you deploy any of these projects.

Dan

--~--~-~--~~~---~--~~
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: browser detection middleware

2007-05-22 Thread Simon Willison

On May 22, 9:38 am, omat <[EMAIL PROTECTED]> wrote:
> Is it a good idea to use a middleware class to detect the browser
> client looking at the HTTP_USER_AGENT so as to serve presentation
> logic accordingly, for mobile devices or older browsers, etc...?

I would advise against this because it won't play well with caching
proxies in between you and the client. If an intermediate proxy caches
your page for Internet Explorer and serves it up to a client running
Firefox stuff will break in very mysterious ways.

You can work around this with the HTTP Vary header, but many proxies
are notoriously badly written so I'm not sure that I'd trust it. Much
better to serve up a standards compliant site for Firefox/Safari/Opera
and have a single stylsheet included using conditional comments for
any specific IE fixes.

Cheers,

Simon


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



unit tests: database confusion

2007-05-22 Thread jararaca

A short while ago I had my unit tests up and running, including
reading some objects from a fixture. Today I've tried to run the tests
again (calling 'manage.py test' just as I did before). Now the test
database is created as I can see using the MySQL Frontend, but the
objects from the fixture never show up there - in spite of the command
line output telling me they have been installed. Furthermore I get
lots of errors like "Failed to install index for ... 'Duplicate key
name...'".
But the strangest part is yet to come: When testing, it is obviously
always my "real" database that is being read, not the 'test_xy'
database, even if I change DATABASE_NAME in settings!
This is so weird. Do you have any idea what might have gone wrong?

Micha


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



"showable" but not "editable" field in the Admin screens

2007-05-22 Thread Seiji - technics
Hi all,
 
Is there a way to show as specific field in the admin screens but
without permitting to edit it?
I want something similar to "editable=False" option but without
excluding the field from the screen.
 
Thanks in advance for the help.
 
Seiji
 
 
 

--~--~-~--~~~---~--~~
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: browser detection middleware

2007-05-22 Thread omat

I agree your comments. My primary concern is to have a reasonably
similar presentation in most popular browsers. I would prefer a one-
css-fits-all solution, but...

In most cases this just doesn't seem possible. The source of wikipedia
discouraged me. Even in their relatively simple layout, they are using
6 additional css s and an additional javascript to fix IE bugs.

Anyway, this is going a little off topic, so I would not discuss css
problems here.



On 22 Mayıs, 12:11, Atilla <[EMAIL PROTECTED]> wrote:
> On 22/05/07, omat <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > Is it a good idea to use a middleware class to detect the browser
> > client looking at the HTTP_USER_AGENT so as to serve presentation
> > logic accordingly, for mobile devices or older browsers, etc...?
>
> > I know this is mostly done by 

Re: browser detection middleware

2007-05-22 Thread Atilla

On 22/05/07, omat <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> Is it a good idea to use a middleware class to detect the browser
> client looking at the HTTP_USER_AGENT so as to serve presentation
> logic accordingly, for mobile devices or older browsers, etc...?
>
> I know this is mostly done by 

Re: Admin custom widget

2007-05-22 Thread Jens Werner

I found the solution.

It is very simple. I need only a directory named 'widget' in my
project-template-directory.

Thats all!


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



browser detection middleware

2007-05-22 Thread omat

Hi all,

Is it a good idea to use a middleware class to detect the browser
client looking at the HTTP_USER_AGENT so as to serve presentation
logic accordingly, for mobile devices or older browsers, etc...?

I know this is mostly done by 

Re: Apache configuration

2007-05-22 Thread Vance Dubberly

James,
  If I get you right the request path is ^mysite/admin/ so ^admin
shouldn't work. You've got to update all your  top level urls to
^mysite/module_name  as such

(r'^mysite/admin/', include('django.contrib.admin.urls')),

  Also the stuff in the virtual host isn't neccesary if you are
mounting via Location. Location defined at the server root trancends
all virtualhosts.

  Frankly if you have the ability to add virtualhosts to your sever
you're best off setting up a virtualhost for every django app.

Vance

On 5/21/07, dystopia <[EMAIL PROTECTED]> wrote:
>
> I've got this in my Apache httpd.conf:
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> PythonPath "['/var/www/dev.django.exampleurl.co.uk/'] + sys.path"
> SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> PythonDebug On
> 
>
> I also have this set up in my vhosts:
>
> 
> ServerName dev.django.exampleurl.co.uk
> DocumentRoot /var/www/dev.django.exampleurl.co.uk/
> PythonPath "['/var/www/dev.django.exampleurl.co.uk/'] +
> sys.path"
> SetEnv mysite.settings
> 
>
>
> If I access the site on "http://dev.django.exampleurl.co.uk/mysite/; I
> get the pretty welcome message. However when I enable the routing
> rules for the generated admin area I get nasty messages telling me
> (understandably) that the rules have not matched anything ^admin/.
>
> I'm worried that I haven't set this up properly, because in effect the
> application (which is for test purposes) should really run off the
> main domain rather than requiring to be accessed through a folder.
>
> Any ideas appreciated
>
> James
>
>
> >
>


-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida

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



django and Dreamweaver CS3

2007-05-22 Thread Merric Mercer

Does anybody know if it is possible to set up Dreamweaver CS3 to edit 
web pages, dynamically created by Django.Dreamweaver works with PHP 
and various other scripting tags - anybody have any experience with it 
and Django?

MerMer

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



Best-practices for form with image

2007-05-22 Thread Xin Xic

Hello,

First, sorry for my english.


Well, I want out a form for a human verification with an image and an 
input field. But I don't know how is the best practice for make this. 
How do you do it?

I need print:
  - An image (different in each case)
  - An hidden input with data relationated with the image.
  - An input field for write de response.

I have thank 3 options:
   1.- Create a extended hidden widget for print the image.
   2.- Create a multi-field that verify itself image, hidden and 
response fields
   3.- Print the image within a form function with hidden and input 
fields, and verify data in form
   4.- Option 3 but verify data out of form.


What do you think?
Thanks



Salut i força al canut,

--~--~-~--~~~---~--~~
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: Forcing unit test runner to abort after failed test

2007-05-22 Thread simonbun

I looked at this again this morning and it appears that unit tests
within a test class do run in alphabetical order after all. This is
handled by the sortTestMethodsUsing property of the TestLoader class
of the unittest lib itself. Maybe this has changed in a newer version,
but in mine (2.4.4) this is the case.

To provide a solution to my own problem: it's possible to catch the
KeyboardInterrupt exception by overriding the 'run' method of the
TestCase class. Seeing as it might be useful to some, I've made a tiny
snippet out of it:

http://www.djangosnippets.org/snippets/247/

regards,
Simon



On May 18, 12:55 pm, simonbun <[EMAIL PROTECTED]> wrote:
> Ah, should have refreshed before replying...I had placed a test_a,
> test_z, test_zz in a particulartestclass and they ran
> alphabetically, but that was probably a coincidence apparently.
>
> Too bad this can't be done (yet). Thanks for the info anyway.
>
> regards,
> Simon
>
> On May 18, 12:49 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On 5/18/07, simonbun <[EMAIL PROTECTED]> wrote:
>
> > > Hi all,
>
> > > I have unit tests for a particular app that take about 2 minutes to
> > > complete. Needless to say, adding new unit tests to this app and
> > > running them is a time consuming process. I know that the old unit
> > > tests will succeed and am basically only interested in the results for
> > > the new unittest.
>
> > > As far as I can tell, unit tests get run in reversed order (newer
> > > first).
>
> > Incorrect. They run in dictionary order (which is to say, effectively
> > random order) within any giventestclass.Testclasses for an
> > application are run in the the order they are defined in models.py,
> > followed by any tests defined in tests.py. Each application is tested
> > in the order listed in INSTALLED_APPS.
>
> > > Is there a way to achieve what I want?
>
> > Not at the moment. I've been meaning to revisit thetestrunnerto add
> > the ability to run a specifictestcase ortestclass by name, but I
> > haven't had a chance to work on this yet.
>
> > 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
-~--~~~~--~~--~--~---



Re: Displaying my table data

2007-05-22 Thread Vance Dubberly

My bet would be that this little bit of code right here:

def __str__(self,):
   return self.choice

the return of __str__ needs to be a string not an object.

Vance

On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> I am trying to display the table in my Choice table.  However it's
> error's out everytime I try to see the contents of the table.
>
> In my python shell prompt I do the following and get the error
>
> C:\django\mysite>python manage.py shell
> (InteractiveConsole)
> >>> from mysite.rugs.models import Choice
> >>> c = Choice.objects.all()
> >>> c
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> 102, in _
> _repr__
> return repr(self._get_data())
>   File "c:\Python24\lib\site-packages\django\db\models\base.py", line
> 86, in __r
> epr__
> return '<%s: %s>' % (self.__class__.__name__, self)
> TypeError: __str__ returned non-string (type Style)
> >>>
>
> Here are my choice models file
>
> class Choice(models.Model):
> choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
>
> def __str__(self,):
> return self.choice
>
> Does anybody know why I can't display the data in the table?
>
>
> >
>


-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida

--~--~-~--~~~---~--~~
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: queryset by custom field

2007-05-22 Thread Malcolm Tredinnick

On Mon, 2007-05-21 at 22:20 -0700, John M wrote:
> Is it possible to order a queryset by a custom field?
> 
> I have several programmatic generated fields and need to sort the
> display by them, is this possible?

The order_by fields are passed to the database and used in the SQL
statement, so you cannot use arbitrary fields there. You are restricted
to database columns (you can't even use computed values from those
columns).

I suspect a workaround is possible, though. All completely untested, but
it doesn't look that hard...

Create a subclass of QuerySet that overrides the __iter__ method. In
your version of __iter__, you call self._get_data(), sort the results
however you want and then return an iterator over the resulting
sequence.

To use this subclass in your models, create a custom manager on your
class that overrides the get_query_set() method of a normal manager.
Your custom method returns your QuerySet subclass, instead of the
QuerySet returned by the default get_query_set().

You can see the details of the default manager that you are going to
override in django.db.models.manager and QuerySet.__iter__ is in
django.db.models.query.

Details of creating a custom manager method are in
http://www.djangoproject.com/documentation/model-api/#custom-managers

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