Re: slug with ForeignKey

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 14:32 -0700, [EMAIL PROTECTED] wrote:
> Not sure why this isn't working.
> 
> I have:
> 
> make = models.ForeignKey(Foo)
> model = models.CharField(maxlength=100)
> slug = models.SlugField(prepopulate_from=('make','model'))
> 
> Foo has
> 
> bar = models.CharField(maxlength=100, unique=True)
> def __str__(self):
>return self.bar
> 
> 
> So slug should populate with bar, right? But instead it's populating
> with the key Id.

It populates it with the formfield values for the fields you specify.
The field value for the "make" field *is* the id of the related object.
The javascript doesn't deep-dive into the string that is used to present
the field, so it doesn't take that into account. This is working as
expected for some definition of "as expected".

Branton's response elsewhere in this thread looks like an interesting
way around this (although a bit counter-intuitive to the user,
possibly).

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: [Announce] Django on Gentoo (DoG) Linux EC2 Image

2007-06-01 Thread Jeremy Dunck

On 6/1/07, mtrier <[EMAIL PROTECTED]> wrote:
>
> If you EC2 (http://aws.amazon.com/ec2) then read on otherwise you can
> ignore all of this.  I've prepared a Django on Gentoo (DoG) Linux
> image for EC2.

Very nice, thanks for sharing.  :)

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



[Announce] Django on Gentoo (DoG) Linux EC2 Image

2007-06-01 Thread mtrier

If you EC2 (http://aws.amazon.com/ec2) then read on otherwise you can
ignore all of this.  I've prepared a Django on Gentoo (DoG) Linux
image for EC2.  This is built on the base Gentoo image that I posted
about previously.  I added a whole bunch of goodness to run Django.
Included are a whole set of startup scripts that build up the system
and initialize the application.  Although this is a long post, please
be sure to read the "Special Instructions" if you want to get maximum
benefit from this image.

AMI ID: ami-29947140
AMI Manifest: eminent-ami/django/10/image.manifest.xml

About this AMI
--

* Published by Eminent Consulting Group ([http://
www.djangoconsulting.com]).
* Django on Gentoo (DoG) Linux System
* This image contains a Gentoo Linux 2007.0 installation with
Django application support.
* Gentoo Linux
- dhcpcd,
- logrotate,
- all packages are recent and updated,
- AMI tools have been installed and are fully working 
even for
volume imaging,
- EC2 meta-data is fetched from 169.254.169.254 into 
/var/spool/ec2/
meta-data,
- EC2 meta-data and user-data include files in 
/var/spool/ec2/meta-
data and /var/spool/ec2/user-data respectively,
- Disabled password authentication in 
/etc/ssh/sshd_config
- Modifications to startup according to Amazon 
documentation
- the portage tree has been bind-mounted to 
/mnt/usr/portage to
preserve space on the root file system,
- the /tmp directory has been bind-mounted to /mnt/tmp 
to preserve
space,
- the /var/lib/postgresql directory has been 
bind-mounted to /mnt/
var/lib/postgresql,
- the root home directory contains a dev-copy directory 
that is
needed to build the volume images,
- all packages have been recompiled to correctly 
respect the Xen
environment.

* Django
- Apache 2.2.4 installed (not in startup) and 
configured with
Python support,
- Python 2.5.1,
- mod_python,
- Postgresql 8.2.4 (not in startup),
- psycopg2
- Subversion 1.4.3 (no repositories are setup)
- Django trunk version checked out into 
/home/django/django and
installed as normal into the Python site-packages directory (django-
admin.py copied to /usr/local/bin/),
- Support packages: libjpgeg, zlib, freetype2, zip, and 
unzip,
- Python packages: PIL 1.1.6, FeedParser 4.1, Markdown 
1.6, Unipath
0.1,

* This image contains the following daemons / services:
- local
- net.eth0 / net.eth1
- netmount
- dhcpcd
- sshd
- syslog-ng
- vixie-cron
- apache 2 (disabled by default)
- postgresql (disabled by default)


Special Instructions


Sample Application
--
The instance can accept a set of user data parameters for setting up
an application.  I've provided a default application to indicate the
process for creating your own application setup scripts.  If you run
the instance with the following parameters it will startup a complete
running default application based on the Django Vote tutorial.

ec2-run-instances ami-29947140 -k gsg-keypair -d "app=mysite-
setup=http://s3.amazonaws.com/eminent-ami/mysite-setup.tgz;

Once the server is up and running you should be able to to enter the
public hostname (starts with ec2) into  your browser and view the
application.  The Admin section of the application is in the location /
admin.  Credentials are:

Username: admin
Password: password

The default application will be installed into the /home/django/mysite
directory.  The setup scripts for the application will get installed
into /opt/mysite-setup.  The Admin media directory and the mysite
media directory are both symbolically linked to the /var/www/mysite/
htdocs directory.


Postgresql Configuration

Postgresql is installed but there is no database setup and the service
is not started by default.  The database directory /var/lib/postgresql
is bind mounted to /mnt/var/lib/postgresql.  The configuration files
have been configured according to the Gentoo Postgresql How-To (http://
gentoo-wiki.com/HOWTO_Configure_Postgresql) document with the included
logging changes.  Configuration files are symbolically linked in from /
etc/postgresql for those that like that sort of thing.  A sample of
creating and restoring the database can be found in the mysite-setup

Re: slug with ForeignKey

2007-06-01 Thread sansmojo

The easiest way I know of is letting the javascript do its thing and
then overriding the save method.  Basically, just split the generated
slug (which will be something like "1-stuff", where 1 is the id of the
Foo instance and "stuff" is the string typed into the model field).
Then grab the instance of Foo, and from that get the value of bar and
recreate the slug:

class Foo(models.Model):
bar = models.CharField(maxlength=100, unique=True)

def __str__(self):
return self.bar

class Admin:
pass

class Nyar(models.Model):
make = models.ForeignKey(Foo)
model = models.CharField(maxlength=100)
slug = models.SlugField(prepopulate_from=('make', 'model'))

def save(self):
slug_parts = self.slug.split('-')
foo = Foo.objects.get(id=slug_parts[0])
self.slug = "%s-%s" % ( foo.bar, slug_parts[1] )

super(Nyar, self).save()

class Admin:
pass

Branton


--~--~-~--~~~---~--~~
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: Newbie Question: URLconf suggestions

2007-06-01 Thread SmileyChris

Perhaps:

.../from/2007-02-07/

.../until/2007-03-07/

.../from/2007-02-07/until/2007-03-07/

On Jun 2, 7:40 am, cjl <[EMAIL PROTECTED]> wrote:
> D:
>
> I am in the process of learning Django, and I'm trying to build a very
> simple mapping application similar to chicagocrime or
> newhavencrimelog.
>
> I like the URLconf that chicagocrime uses for displaying crimes by
> type:
> /crimes/arson
> /crimes/burglary
>
> This makes sense, and the urls look nice.  I'm stumped on the "right"
> way to handle dates or date ranges in a URLconf...newhavencrimelog
> allows you to limit your search by a date range, however this
> information in not reflected in the URL...I'm guessing this is passed
> as session data? Chicagocrime has a URLconf for a single date, but not
> for ranges:
>
> /2007/feb/07
>
> Anyway, I would like some suggestions on a URLconf for date
> ranges...anyone doing this?
>
> Thanks in advance,
> CJL


--~--~-~--~~~---~--~~
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: Case insensitive urls

2007-06-01 Thread sansmojo

Just pull your regular expression into a variable and use re.I or
re.IGNORECASE.  Fore example:

urls.py:
from django.conf.urls.defaults import *

import re
re_admin = re.compile(r'^admin/', re.I)

urlpatterns = patterns('',
(re_admin, include('django.contrib.admin.urls')),
)

This will allow a match for any case: /admin/, /aDmiN/, /ADMIN/


--~--~-~--~~~---~--~~
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: Case insensitive urls

2007-06-01 Thread SmileyChris

Hi Ramashish,

I haven't tried it, but I think that you could just use regular
expression extension notation to make the regex case insensitive in
your url conf.
So instead of:
  ('users/add/', 'views.add'),
You'd do:
  ('(?i)users/add/', 'views.add'),

Try it and let everyone know if that works...

On Jun 2, 1:35 pm, Ramashish Baranwal <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I would like to make urls of my site case-insensitive. As I
> understand, by default the url matching is case-sensitive. Is there a
> way to specify in my urls.py that I want a case-insensitive match?
>
> 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: Migrate data between computers

2007-06-01 Thread Russell Keith-Magee

On 5/31/07, Michal <[EMAIL PROTECTED]> wrote:
>
> I trust to my data, so I temporary disabled save() overriding. Now
> loaddata was successfull, and my application on computer2 works like charm.

Good to hear. I've opened ticket #4459 to address the problem; I've
got some ideas on how to fix the issue, but I need to have a closer
look.

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: Decimals with Python 2.3.4

2007-06-01 Thread sansmojo

Ah!  That's it, but I was a revision behind and didn't notice.  It was
obviously caught since then.  Thanks, Russ!

Branton


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



miss universe 2007

2007-06-01 Thread hiruma222

miss universe 2007
http://www.real-article.com/miss%20universe/index.htm


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



Case insensitive urls

2007-06-01 Thread Ramashish Baranwal

Hi,

I would like to make urls of my site case-insensitive. As I
understand, by default the url matching is case-sensitive. Is there a
way to specify in my urls.py that I want a case-insensitive match?

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: problems using django on lighttpd with fastcig

2007-06-01 Thread Justin Bronn

I've had great success with lighty & django, and actually prefer using
it over apache.

> server.modules = (
> ...
>   "mod_fastcgi",
>   "mod_accesslog"
> )

I believe this might be your problem.  When using lighttpd the
ordering of the server modules is important and 'mod_fastcgi' _must_
be the last module loaded.  I've created an example lighttpd
configuration file (w/comments):
http://media.houstoncrimemaps.com/django-lighttpd.conf

Regards,
-Justin


--~--~-~--~~~---~--~~
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: Serialize with foreign key

2007-06-01 Thread Russell Keith-Magee

On 6/2/07, emailgregn <[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> How can I get foreign key fields serialized ?

The problem you have is not to serialize the keys, but to find the
dependencies that need to be serialized. Although the serializer _can_
take a queryset, it only does so as a degenerate case of a list of
objects. You can pass _any_ list of _any_ objects into the serializer,
and it will spit them out as serialized data. So:

jstr = serializers.serialize('json', list(Book.objects.all()) +
list(Author.objects.all()))

will serialize all the books and authors.

However, if you only want the authors related to a subset of books,
you will need to do some filtering. There isn't currently a built-in
method for determining dependencies, so you'll need to work out the
dependency list yourself.

In your specfic case, you can filter fairly easily by getting all the
books, then getting all the authors from those books. The generic case
is a little harder, but shouldn't be too difficult. If you (or anyone
else for that matter) wanted to contribute a generic dependency
generating algorithm, I'd be happy to commit it to trunk.

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



Decimals with Python 2.3.4

2007-06-01 Thread sansmojo

Hello all!

I just upgraded to the latest development version of Django and am now
getting an error from the admin (which only happens when trying to
save a form with DecimalField).  The error looks like this:

mportError at /ce/admin/programs/event/111/
cannot import name decimal

Request Method: POST
Request URL:http://cestest.washburn.edu/ce/admin/programs/event/111/
Exception Type: ImportError
Exception Value:cannot import name decimal
Exception Location: /usr/lib/python2.3/site-packages/django/oldforms/
__init__.py in html2python, line 785


So, I checked out the code there, and it tries to import decimal,
which doesn't exist in my version of python.  However, it tries an
alternate import of django.utils.decimal, which doesn't exist.  There
is, however, a django.utils._decimal.  Is this a bug or should I
replace decimal with _decimal?

Thanks!

Branton


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



Custom Model Field Help

2007-06-01 Thread Sean

Greetings,

I am in the process of writing a custom model field.  Its basically an
encrypted char field, the idea is that when ever the field is saved to
the database it would be encrypted and when it is loaded back from the
database it would be decrypted.

I have gotten the encryption and decryption code down and I have been
able to override the appropriate functions so that the data is
encrypted when it is saved to the database.  Unfortunately I have not
been able to figure out what function to override to decrypt the data
when it is loaded from the database.

Additionally I have a strange problem where any time I include this
custom field in a model, that model no longer appears in the Django
admin.  There doesn't seem to be any errors in the field/model since I
can use it with out problems from the shell.

Any help or insight would be greatly 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-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: Signal for 'ready to receive requests'

2007-06-01 Thread Doug B

I have an event manager that is a bit like a database driven
pydispatch combined with a general logging/monitoring app.
Embarassingly enough I wrote it before learning about pydispatch and
signals.  So much for not reinventing the wheel.  It keeps track of
various events, calls registered callback functions on those events,
and depending on settings for that event type it may log it to the
database, syslog, or cache it for a period of time waiting for a
related event.

It's django model aware for logging of object types, keys and model
specific info by use of a mixin class (which references the manager)
to go along with models.Model.  That has a side effect of causing the
manager to load before all of the model relations are complete, making
getting the configuration from the database tricky if I want to use
the orm. There are a number of possible hacks I think will work to get
around it for this, but it just seemed like a 'django is ready, do
your own init if you want to' signal would make the most sense if it
existed.

For now I just don't allow any event at module level, and the first
event logged triggers a sync with the database when it doesn't fnd the
information in the cache.  I'll probably just keep it this way so I
can periodically requery the database for updated configuration when
the cache expires.

I hope this isn't being posted twice, but it's been an hour or two and
the original reply hasn't found its way here yet.


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



slug with ForeignKey

2007-06-01 Thread [EMAIL PROTECTED]

Not sure why this isn't working.

I have:

make = models.ForeignKey(Foo)
model = models.CharField(maxlength=100)
slug = models.SlugField(prepopulate_from=('make','model'))

Foo has

bar = models.CharField(maxlength=100, unique=True)
def __str__(self):
   return self.bar


So slug should populate with bar, right? But instead it's populating
with the key Id.

Any ideas?


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



Generic views: how to use them properly?

2007-06-01 Thread Sacher Khoudari

Hello!

I'm new to Django, and are currently playing around a bit. I've
finished the tutorial, and have just started a small sample app. I
really like Django. Although its different to everything I have done
before (I confess, it was only PHP, I don't know Rails, Tomcat, Zope
or anything else), you can get into it very quickly. The tutorial is
great, and I think I'm understanding the design philosophies.

But, I have some trouble with the generic views. They are great,
really, but either they lack a simple feature I think they should
have, or they lack some proper documentation, or I'm a idiot and don't
know how to use Google.

Ok, given the following situation: I have two models, one depends on
the other by a foreign key. Call them

class Author:
name = models.CharField(maxlength=32)

class Book:
author = models.ForeignKey( Author )

Now I can get a list of all authors in my database, a list of all
books by author, details for each book, I can edit and delete each
book... that works all fine. And, it's really easy to do that. But how
can I add a book to an author? I mean, how do I call
"django.views.generic.create_update.object_create" with "model=Book",
and pass it the value for it's foreign key?

Here is the URL pattern I want to use:

urlpatterns = patterns('django.views.generic.create_update',
 (r'^authors/(?P\w+)/add_book/$', 'object_create',
dict(model=Book,slug_field='name')),
 )

Ok, instead of the author's name (as slug) y could have used it's ID.
But that doesn't matter. Anyway, doing this I get an error. I don't
have the error message here right now (I'm sorry, I'm developing/
playing around at home, but I don't have an internet access there, so
I'm on another computer), but it tells me, that object_create does not
expect this "slug" field. "object_id" doesn't work either. The
documentation (even the open book) doesn't tell me anything about
that. Google doesn't find much if I search for "object_create".

Any ideas/hints/solutions? Is this a missing feature? Or does Django
lack this feature by intention? Or have I missed something? I don't
want to teach you in philosophy or design goals, but I think this
should be part of the generic views' features. It's a further simple
(generic) action I would like to make use of.

Thanks!
Sacher


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



Newbie Question: URLconf suggestions

2007-06-01 Thread cjl

D:

I am in the process of learning Django, and I'm trying to build a very
simple mapping application similar to chicagocrime or
newhavencrimelog.

I like the URLconf that chicagocrime uses for displaying crimes by
type:
/crimes/arson
/crimes/burglary

This makes sense, and the urls look nice.  I'm stumped on the "right"
way to handle dates or date ranges in a URLconf...newhavencrimelog
allows you to limit your search by a date range, however this
information in not reflected in the URL...I'm guessing this is passed
as session data? Chicagocrime has a URLconf for a single date, but not
for ranges:

/2007/feb/07

Anyway, I would like some suggestions on a URLconf for date
ranges...anyone doing this?

Thanks in advance,
CJL


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



Integrating Selenium web tests with django test suite

2007-06-01 Thread Almad

Hi,

I'd like to ask how do you integrate your webtests with django suite,
so it'll be run on manage.py test.

I've looked for resources support for unittest framework, but I have
not found any way how to skip test gracefully (I guess it's patched
for python 2.6), but for now I'd then prefer starting selenium server
manually from python by creating SeleniumTestCase. However, I have
problems to determine when is selenium server really started and

self.p = Popen(['java', '-jar', config.get('selenium',
'path'), '-port', str(config.get('selenium', 'port'))], \
   stdout=PIPE, stdin=PIPE, stderr=PIPE)
# wait until server start
#FIXME find a way to resolve that server is started
sleep(2)

is just ugly.


How do You integrate Your tests with Selenium?

Thank You,

Almad


--~--~-~--~~~---~--~~
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: json serializing without certain fields

2007-06-01 Thread emailgregn

this had me stumped.
thanks for the fix
G

On Jun 1, 3:44 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 6/1/07, web-junkie <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
> > how can I get JSON out of my Django object without having certain
> > fields in there for obvious reasons?
> > I found solutions like serializers.serialize("json",
> > Something.objects.all(), fields='myfield' )
> > which do not work, there's also a ticket on 
> > thathttp://code.djangoproject.com/ticket/3466
> > Why isn't that solved by now and how can I get it to work the way I
> > want?
>
> For whatever reason, the triage team hadn't promoted that ticket to
> 'ready for checkin' status. That doesn't mean the ticket wasn't ready
> for checkin - just that nobody had given it enough attention as yet.
>
> Like Malcolm said, we're all volunteers here. Complaining about the
> speed of the bug fixing process doesn't solve the problem. If you want
> things to move faster, feel free to help out.
>
> However, that said, now that we are aware of the problem, it was an
> easy fix, committed as [5409].
>
> 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: form required field question

2007-06-01 Thread Joseph Kocherhans

On 6/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Thanks... that does look like what I'm looking for. I don't really
> understand how I'd put it in a model, though... I've got a situation
> where if the choose a, they need to choose from one list, if they
> choose b, they need to choose from another, and so on, but this is all
> in the admin.. no public form.

Instantiate RequiedIfOtherFieldEquals, and put it in the
validator_list argument of your optional fields. Something similar to
this should work:

class MyModel(models.Model):
required_field = models.CharField()
opt_field_a = models.IntegerField(
choices=C1,
validator_list=[RequiedIfOtherFieldEquals('required_field', 'a')]
)
opt_field_b = models.IntegerField(
choices=C2,
validator_list=[RequiedIfOtherFieldEquals('required_field', 'b')]
)

Joseph

--~--~-~--~~~---~--~~
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-beancounter accounting app

2007-06-01 Thread Peter Baumgartner

Just wanted to ping the list with a code project I uploaded today.
http://code.google.com/p/django-beancounter/

Django-beancounter is a simple app I built to track my income and
expenses as a freelancer. It has a handful of reports built into the
Django admin interface and uses Plotkit for pretty graphs.

Any feedback is appreciated.

-- 
Pete

--~--~-~--~~~---~--~~
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 a drop down selection list

2007-06-01 Thread strelok31

I inherited an application written in Python and I need to make a
change to it. The guy who created it is gone and I am not an expert in
Python. I was able to get one thing to work but I am having difficulty
with another part. I need to add a drop down selection list to the
HTML page and the save the value selected to the MySQL database.
Currently application reads the uploaded file, decrypts the info and
stores the results in MySQL database. The structure is already in
place I just need to add the drop down selection list. Any help would
be greatly appreciated. I have already added a field to the table.

This is the code for the HTML page. Keyfile is the name of the file.

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>

http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">



AccuRateS




AccuRateS - Upload License Key File

Select file:  
 Sales Person:

Angelo
Debbie
James
Gabe
Mark H
Mike
Rob
Ron W
Yieciel






--
--
this is the python utility file that decrypts the info in the uploaded
file and generates a field dictionary for database insertion

def load_file(fname):
'''Loads the AccuraRates license file, reads the first line and splits
the contents by colon'''
f = open(fname,'r')
line = f.readline()
line = line.replace('\r\n','')
return line.split(':')

def load_string(s):
'''Loads the AccuraRates license file content passed as a string,
reads the first line and splits the contents by colon'''
s = s.replace('\r\n','')
return s.split(':')

def parse_fields(l):
'''Takes a list of the data values in the AccuRateS and generates a
field dictionary for database insertion'''
import time, datetime
d = {'rio':'',
'days_licensed':'',
'volume_id':'',
'keygen_date':'',
'accu_id':''
}

d['days_licensed'] = int(l[0]) # days_licensed
d['volume_id'] = l[1] # volume id
d['accu_id'] = l[(len(l)-1)] # accuid
d['rio'] = d['accu_id'][:-12] # rio code is accuid minus 12 digit
timestamp appendix

# format keygen date
epochsecs = time.mktime( time.strptime(l[2], '%m/%d/%Y') )
kgd = datetime.datetime.fromtimestamp(epochsecs).date()
d['keygen_date'] = kgd

return d

def parse_content(c):
# scrub the input string and split
l = load_string(c)
cleartext = decrypt_string(l[0],l[1])
return parse_fields( cleartext.split(':') )

if __name__ == '__main__':
pass

-
this is a python file where database insertion is done. But it does
not work after my changes
--
# Create your views here.
from django.utils.httpwrappers import HttpResponse,
HttpResponseRedirect
from django.core.extensions import render_to_response
from django.core.extensions import DjangoContext
from django.core.exceptions import Http404
from django.core.template import loader
from accurates.apps.accukeys import util
from django.models.accukeys import acculicenses
from django.views.decorators.auth import login_required

def index(request):
t = loader.get_template("accukeys/index")
c = DjangoContext(request, {'foo':'yeah'})
return HttpResponse(t.render(c))
#return render_to_response("accukeys/index", {'foo':'yeah'})

def upload_key(request):
if not request.FILES.has_key('keyfile'):
raise Http404
# get the file info
fileinfo = request.FILES['keyfile']
try:
field_dict = util.parse_content(fileinfo['content'])

# make a new accu_license object
al = acculicenses.AccuLicense(
rio=field_dict['rio'],
days_licensed=field_dict['days_licensed'],
volume_id=field_dict['volume_id'],
keygen_date=field_dict['keygen_date'],
accu_id=field_dict['accu_id'],
sales_person = document.Submit.salespeople_dropdown.value # I added
this line
)
# commit to database
al.save()

# store in session
request.session['license']=al

return HttpResponseRedirect("/confirmation/")
except:
raise Http404

def confirmation(request):
if 'license' in request.session:
license = request.session['license']
else:
license = None

return render_to_response("accukeys/confirmation", {'license':license})


--~--~-~--~~~---~--~~
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: json serializing without certain fields

2007-06-01 Thread web-junkie

Sorry for being a littly bit offensive.
Thanks for your replies and for commiting the patches, works like a
charm now.

On Jun 1, 3:44 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 6/1/07, web-junkie <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
> > how can I get JSON out of my Django object without having certain
> > fields in there for obvious reasons?
> > I found solutions like serializers.serialize("json",
> > Something.objects.all(), fields='myfield' )
> > which do not work, there's also a ticket on 
> > thathttp://code.djangoproject.com/ticket/3466
> > Why isn't that solved by now and how can I get it to work the way I
> > want?
>
> For whatever reason, the triage team hadn't promoted that ticket to
> 'ready for checkin' status. That doesn't mean the ticket wasn't ready
> for checkin - just that nobody had given it enough attention as yet.
>
> Like Malcolm said, we're all volunteers here. Complaining about the
> speed of the bug fixing process doesn't solve the problem. If you want
> things to move faster, feel free to help out.
>
> However, that said, now that we are aware of the problem, it was an
> easy fix, committed as [5409].
>
> 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: Looking for Django Developers As Founders

2007-06-01 Thread [EMAIL PROTECTED]

if i click "view profile" within your posts, I can then click on the
linked elipsis in the middle of your email =)

On May 31, 3:44 pm, Michael Lim <[EMAIL PROTECTED]> wrote:
> Nic,
>
> Not in Google Groups. The email is masked off as shown in the reply
> thread shown below :-)
>
> Have a nice day!
>
> Cheers,
> Michael
>
> On Jun 1, 3:41 am, Nic James Ferrier <[EMAIL PROTECTED]>
> wrote:
>
> > Michael Lim <[EMAIL PROTECTED]> writes:
> > > Hi all,
>
> > > Sorry, my email is
>
> > > lim  ck  michael  gmail  com
>
> > Ermmm It tells us that in the mail header.
>
> > --
> > Nic Ferrierhttp://www.tapsellferrier.co.uk


--~--~-~--~~~---~--~~
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: form required field question

2007-06-01 Thread [EMAIL PROTECTED]

Thanks... that does look like what I'm looking for. I don't really
understand how I'd put it in a model, though... I've got a situation
where if the choose a, they need to choose from one list, if they
choose b, they need to choose from another, and so on, but this is all
in the admin.. no public form.

On May 31, 5:04 pm, "Joseph Kocherhans" <[EMAIL PROTECTED]> wrote:
> On 5/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> >  I have the common scenario where if the user selects "other", then I
> > need an "explain" box to become required. How can I do this?
> > Additional validator on the field or something?
>
> You probably want django.core.validators.RequiredIfOtherFieldEquals
>
> Joseph


--~--~-~--~~~---~--~~
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 a bug: f.data = data return False instead of True ?

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 13:56 +, olive wrote:
> Malcom,
> 
> I don't see any bound_data attribute.

Typo. It's called is_bound, not bound_data. Open up newforms/forms.py.
Have a look in BaseForm.__init__. All the answers are there.

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: Is it a bug: f.data = data return False instead of True ?

2007-06-01 Thread olive

Malcom,

I don't see any bound_data attribute.

Can you give me an example please ?

I'm using 0.96 by the way.

Olive.


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



Newforms is_bound determination (was Re: Is it a bug: f.data = data return False instead of True ?)

2007-06-01 Thread Benjamin Slavin

On 6/1/07, olive <[EMAIL PROTECTED]> wrote:
> This returns True:
> f = myform(data)
> f.is_valid()
>
> while this returns False:
> f = myform()
> f.data = data
> f.is_valid()
>
> Is it a bug ?

Not sure if it should be called a bug or not from a quick look at
the source code (django/newforms/forms.py) it is expected behavior.

When a form is initialize, it determines if it is bound (has data) or
unbound (has no data)
self.is_bound = data is not None

Because you are not providing data when the form is initialized, it
determines that it is unbound and will take a shortcut during
cleaning/validation.

It would be possible to promote is_bound to a Form property to do
on-demand determination of bindedness (?) rather than determining it
at instantiation.

I'm forwarding this to the developers list to see if anyone over there
has any thoughts.

 - Ben

--~--~-~--~~~---~--~~
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 a bug: f.data = data return False instead of True ?

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 13:40 +, olive wrote:
> Hi,
> 
> This returns True:
> f = myform(data)
> f.is_valid()
> 
> while this returns False:
> f = myform()
> f.data = data
> f.is_valid()
> 
> Is it a bug ?

Nope. It just means I gave you some bad advice before. You also need to
set the bound_data attribute on the form when you assign to data.

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: json serializing without certain fields

2007-06-01 Thread Russell Keith-Magee

On 6/1/07, web-junkie <[EMAIL PROTECTED]> wrote:
>
> Hi
> how can I get JSON out of my Django object without having certain
> fields in there for obvious reasons?
> I found solutions like serializers.serialize("json",
> Something.objects.all(), fields='myfield' )
> which do not work, there's also a ticket on that 
> http://code.djangoproject.com/ticket/3466
> Why isn't that solved by now and how can I get it to work the way I
> want?

For whatever reason, the triage team hadn't promoted that ticket to
'ready for checkin' status. That doesn't mean the ticket wasn't ready
for checkin - just that nobody had given it enough attention as yet.

Like Malcolm said, we're all volunteers here. Complaining about the
speed of the bug fixing process doesn't solve the problem. If you want
things to move faster, feel free to help out.

However, that said, now that we are aware of the problem, it was an
easy fix, committed as [5409].

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



Is it a bug: f.data = data return False instead of True ?

2007-06-01 Thread olive

Hi,

This returns True:
f = myform(data)
f.is_valid()

while this returns False:
f = myform()
f.data = data
f.is_valid()

Is it a bug ?

Olive.


--~--~-~--~~~---~--~~
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: json serializing without certain fields

2007-06-01 Thread Gábor Farkas

web-junkie wrote:
> Hi
> how can I get JSON out of my Django object without having certain
> fields in there for obvious reasons?
> I found solutions like serializers.serialize("json",
> Something.objects.all(), fields='myfield' )
> which do not work, there's also a ticket on that 
> http://code.djangoproject.com/ticket/3466
> Why isn't that solved by now and how can I get it to work the way I
> want?

you can always write your own serializer... check how the json one is 
done...

gabor

--~--~-~--~~~---~--~~
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 bind data after instantiation of a new form

2007-06-01 Thread olive


Thanks Malcom.

Please forgive me, it is friday and working with Django is equally
entertaining and tiring.

Have a good WE,

Olive.


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



json serializing without certain fields

2007-06-01 Thread web-junkie

Hi
how can I get JSON out of my Django object without having certain
fields in there for obvious reasons?
I found solutions like serializers.serialize("json",
Something.objects.all(), fields='myfield' )
which do not work, there's also a ticket on that 
http://code.djangoproject.com/ticket/3466
Why isn't that solved by now and how can I get it to work the way I
want?


--~--~-~--~~~---~--~~
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: looping over related objects in templates

2007-06-01 Thread olivier


> This looks like the correct syntax. There are a limited number of
> things that could be going wrong. Either:
> - The author object being provided in the context doesn't have any articles
> - The article doesn't have a 'title' attribute
> - The value of article.title is '' for every article
> - There is a typo in your template that you haven't made in this email.

Yes, one of those occured, I noticed too late
Thank you for you very detailed answer.

Olivier


--~--~-~--~~~---~--~~
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: looping over related objects in templates

2007-06-01 Thread Russell Keith-Magee

On 6/1/07, olivier <[EMAIL PROTECTED]> wrote:
>
> Hi Group,
>
> It seems it is not possible to loop over a RelatedManager in a
> template.

It certainly is possible.

> If I do this :
> {% for article in author.article_set.all %}
>{{article.title }}
> {% endfor %}

This looks like the correct syntax. There are a limited number of
things that could be going wrong. Either:
- The author object being provided in the context doesn't have any articles
- The article doesn't have a 'title' attribute
- The value of article.title is '' for every article
- There is a typo in your template that you haven't made in this email.

Some debugging hints:
- Try putting TEMPLATE_DEBUG_IF_INVALID='INVALID' in your settings
file. This will put some INVALID text into your generated output
whenever a template variable can't be expanded
- Try putting some other content inside the loop (some dummy text) -
This will determine if the loop is occurring.

> I don't get any errors, but no output either.

Not getting errors isn't surprising; the template language generally
fails silently, to prevent the end user seeing things they shouldnt.
Hence the TEMPLATE_DEBUG_IF_INVALID setting for debug purposes.

> Did I miss something ? Or do I have to write a get_articles method in
> the Author model, which the template will know how to handle ?

No. The  object instance can provide sufficient detail to the template
to render related objects.

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: looping over related objects in templates

2007-06-01 Thread olivier

Ooops, sorry, never mind.

> {% for article in author.article_set.all %}
>{{article.title }}
> {% endfor %}

works fine.


Olivier


--~--~-~--~~~---~--~~
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: Dynamic ModelChoiceField

2007-06-01 Thread Dwarf



On Jun 1, 3:27 am, sorrison <[EMAIL PROTECTED]> wrote:
> I am using a ModelChoiceField (default_project) in a form and want the
> initial queyset to change when the form is created.
>
> I've tried doing it like this:
>
> forms.py --
> class UserAccountForm(forms.Form):
>.
>default_project =
> forms.ModelChoiceField(queryset=Project.objects.all(), required=False)
>..
> views.py ---
> form = form = UserAccountForm()
> form.base_fields['default_project'].queryset = user.project_set.all()
>
> But it doesn't change the choices in the form.
> Is there some way I can achieve this?
Sam,
I myself spent hours for a similar issue, I believe.
The point is that the field 'default_project'  is defined at the
compile time and related to the class UserAccountForm,
not to the instance form you create in view.py.
Hence, the queryset is rather a snapshot of Projects table.
You need to define 'default_project' as to be related to the form
instance. Just overrride  constructor of UserAccountForm class.
Something like that:
   def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self.fields['default_project'] =
forms.ModelChoiceField(queryset=Project.objects.all(), required=False)

Of course remove default_project field definition from the class
scope.

Hope it will help.

Oleg.

>
> Thanks
>
> Sam


--~--~-~--~~~---~--~~
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: Newforms / Validation / Uniqueness

2007-06-01 Thread Nebojša Đorđević

On 31.05.2007., at 04:30, Malcolm Tredinnick wrote:

> On Wed, 2007-05-30 at 08:31 -0700, ringemup wrote:
> [...]
>>> So a "uniqueness" constraint on your model is not something that the
>>> form framework is really in a position to check. Instead, what  
>>> should
>>> happen is you construct the model object and then call
>>> object.validate(), which returns ValidationErrors if there are  
>>> problems.
>>> The validate() method on a model will have full access to the model
>>> instance (including "self").
>>
>> Do you then have to figure out which errors apply to which Form
>> fields, and sort them out and assign them?  I haven't seen any sample
>> code doing anything of this sort, so I'd be very interested to see  
>> how
>> it works.
>
> Since full model-aware validation doesn't exist yet, example code  
> would
> be premature. :-)
>
> To sort of answer your question, however: yes, in the cases where you
> are using model-aware validation as part of the form validation, you
> would need to figure out the mapping back. We might be able to make  
> some
> things easier in form_for_model() cases, but, as I say, the code  
> doesn't
> exist yet, so any claims as to what actually happens would be
> hypothetical.

You can see some validation examples and at http://django- 
utils.googlecode.com/svn/branches/0.1/forms/  -- look at the  
`create_object` for the example.

Code is little old but should work.

(sadly, I currently do not have any spare time to work on this :( )

-- 
Nebojša Đorđević - nesh, ICQ#43799892, http://www.linkedin.com/in/ 
neshdj
Studio Quattro - Niš - Serbia
http://studioquattro.biz/ | http://code.google.com/p/django-utils/
Registered Linux User 282159 [http://counter.li.org]



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



looping over related objects in templates

2007-06-01 Thread olivier

Hi Group,

It seems it is not possible to loop over a RelatedManager in a
template.
I have two models, Author and Article, joined by the relevant foreign
key.
For each author, I want to display the list of his articles

If I do, for each author :

{% for article in author.article_set %}
   {{article.title }}
{% endfor %}

I get a TypeError, 'RelatedManager' object is not iterable


If I do this :
{% for article in author.article_set.all %}
   {{article.title }}
{% endfor %}

I don't get any errors, but no output either.

Did I miss something ? Or do I have to write a get_articles method in
the Author model, which the template will know how to handle ?

Cheers,

   Olivier


--~--~-~--~~~---~--~~
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-multilingual newforms-admin branche?

2007-06-01 Thread Russell Keith-Magee

On 6/1/07, Glin <[EMAIL PROTECTED]> wrote:
>
> Hi, I wonder if there is branch of django-multilingual for newforms-
> admin?
>
> I suppose that newforms admin will be merged with trunk in one or two
> releases and lot of people already works with newforms admin, so it
> would be great to have the posibility to work with multilingual models
> in newfomrs-admin, too.

It will be merged much sooner than "one or two releases" time. It is
one of the major prerequisites for the 0.97 release.

Unless I am mistaken, newforms-admin is reasonably close to getting
merged back to trunk. There are still one or two outstanding features
to sort out, but the timeline for the merge is "in the near future",
not "at some point in the future".

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: Should file uploads work in 0.96 admin?

2007-06-01 Thread Thomas Guettler

Am Freitag, 1. Juni 2007 01:35 schrieb Andrew:
> I'm just wondering my expectations are correct:
>
> Using 0.96, given a model with an ImageField, the admin interface
> gives me (what looks to be) a file upload widget.
>
> I should be able to select a file from that widget, and once I save
> the model, it *should* copy my image file into the upload_to path,
> correct?

Yes, I had problems with this yesterday, too. Now it works:

settings.py:

MEDIA_ROOT = '/home/user/docroot/wfba/media'
MEDIA_URL = '/wfba/media/'

The problem was the trailing slash.

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



Investment

2007-06-01 Thread GPcapital

Lately I've been surfing trought some web pages and got this one
www.gpcapitalgroup.com . It looks quite interesting, it may be a great
chance to invest.


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



Making Money Online: Earn Up To 30,000 A Month Working From Home

2007-06-01 Thread [EMAIL PROTECTED]

Don't you wish you could drive your dream car, own your dream house,
take a cruise on your own personal yacht? Isn't it time you stopped
dreaming and started living those dreams?
http://www.cgmoney.com

What do we offer you at http://www.cgmoney.com/
We will show you exactly how to make 30,000 or more a month online! So
what are you doing still here, this is one website you have got to
check out! If you want those dreams to come true and to have more
money than you've ever thought possible then you need to quit delaying
and head over there today!
http://www.cgmoney.com/


--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Gio

Yes, you are right.
Removing core=True solved the issue.

However I think an error message from admin web interface is needed
when things go wrong.
Or should the default model validator to point to the error?
As during all my experiments in the terminal where the server was
running I always got:
---
Validating models...
0 errors found.
---

Notice that if you don't put any core=True in this case you got a
validation issue:
---
Validating models...
pizza.pizzatopping: At least one field in PizzaTopping should have
core=True, because it's being edited inline by pizza.Pizza.
1 error found.
---

Thank you,
Giovanni.



chrominance ha scritto:

> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza,
>   help_text = 'Toppings to go on Pizza:
> num in admin is how many will show up in Pizza',
>   edit_inline = models.TABULAR,
>   num_in_admin = 3,
>   core=True)
> topping = models.ForeignKey(Topping)
> amount = models.IntegerField()
>
> You have core=True set on the same field that has edit_inline, which
> doesn't make any sense if you read the model documentation. core=True
> should only be set on fields other than the ForeignKey field with
> edit_inline set. Setting core=True on a field means you're making that
> field a required field; it's so the admin knows when a related object
> should be deleted, simply by checking if all the core=True fields have
> been filled out.
>
> In this particular instance, you've set edit_inline on the pizza
> field, which means PizzaTopping shows up as part of the Pizza admin.
> Setting core=True on topping and amount would mean both topping and
> amount would have to be filled out before the admin site will save a
> PizzaTopping object. I don't know what happens if you set core=True
> and edit_inline=models.X on the same field, but it probably isn't
> pretty.


--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread chrominance

class PizzaTopping(models.Model):
pizza = models.ForeignKey(Pizza,
  help_text = 'Toppings to go on Pizza:
num in admin is how many will show up in Pizza',
  edit_inline = models.TABULAR,
  num_in_admin = 3,
  core=True)
topping = models.ForeignKey(Topping)
amount = models.IntegerField()

You have core=True set on the same field that has edit_inline, which
doesn't make any sense if you read the model documentation. core=True
should only be set on fields other than the ForeignKey field with
edit_inline set. Setting core=True on a field means you're making that
field a required field; it's so the admin knows when a related object
should be deleted, simply by checking if all the core=True fields have
been filled out.

In this particular instance, you've set edit_inline on the pizza
field, which means PizzaTopping shows up as part of the Pizza admin.
Setting core=True on topping and amount would mean both topping and
amount would have to be filled out before the admin site will save a
PizzaTopping object. I don't know what happens if you set core=True
and edit_inline=models.X on the same field, but it probably isn't
pretty.


--~--~-~--~~~---~--~~
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-multilingual newforms-admin branche?

2007-06-01 Thread Glin

Hi, I wonder if there is branch of django-multilingual for newforms-
admin?

I suppose that newforms admin will be merged with trunk in one or two
releases and lot of people already works with newforms admin, so it
would be great to have the posibility to work with multilingual models
in newfomrs-admin, too.


--~--~-~--~~~---~--~~
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: Serving static media, again...

2007-06-01 Thread Kelvin Nicholson


> So, I have one server with apache2+mod_python and Lighttpd installed. 
> What is the best solution for serving static content?
> 

Is it a safe assumption that you only have one IP to work with?

I'm certainly not claiming to be an expert, however I'll extend a few
thoughts.  Maybe in your situation you should put a thread enabled
(lighttpd/apache+worker+mod_proxy) web server first, with the dynamic
content as a heavy backend server.  In theory you could also setup
caching on the lightweight front server.  Maybe take a look at squid as
well (and pumping media.domain.com to lighttpd on say port
127.0.0.1:8081 and domain.com to apache/mod_python on port
127.0.0.1:8082).

Just tossing out ideas,

Kelvin


-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 289090AC
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.com



--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Gio

Let me add that it isn't a Python version problem, it's the same with
python 2.4 and 2.5.

Giovanni.


--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Gio

@Malcom
Thanks. I forgot about that example!

@Michael
This is what I do:
1. I create a new project with the model file made by a copy-and-paste
of the code I posted above. I add my new app to configuration files.
2. I create a new db and I create tables it with syncdb
3. manage.py runserver and I go to admin web interface, accessing it
with username and password
4. I see all the right things there, so I go on and I create a few
toppings
5. I create a pizza, giving to it the right toppings, in the right
amount
6. I hit the "save" button and I got a "success" answer

But: while the pizza is there (name got the right value) there aren't
toppings associated with it. Indeed inspecting the db the generalized
ManyToMany table we are using is still empty. Toppings table got the
right entries of course.
And no errors in my terminal where the server is running.

Doing  same things with no "edit_inline" require a few more steps
(defining a pizza before associating toppings) but everything goes the
right way.
I'm always speaking about the admin web interface. Never touched the
shell during the whole process.

Where should I look further?

Regards,
Giovanni.


On 1 Giu, 10:17, Michael Newman <[EMAIL PROTECTED]> wrote:
> I use this code in quite a few of my programs and never have issues. I
> don't know why you are having this problem and it is not throwing any
> errors. Are you using the Web interface at all? If so when saving are
> there any errors. If the objects aren;t saving to the db generally
> Python throughs some erros that can point the to the problem.
> The next guess I would tell you is to use the related_name variable to
> rename the foreign key so the code doesn't confuse the variables.
>
> Malcolm is right on this one; you need to figure out exactly what is
> going on before you submit a bug, because otherwise you are just
> wasting the programmers' time trying to reproduce the problem. Let's
> exhaust all the other possibilities first and figure out what is going
> on.
>
> Hope that helps,
> Mn
>
> On Jun 1, 3:46 am, Gio <[EMAIL PROTECTED]> wrote:
>
> > > The usual process when you have one version of code that is working and
> > > a more complicated version that is not working is to add features to the
> > > working version, one at a time, until it stops working. In that way you
> > > will be able to narrow down exactly which is the problematic step and
> > > then work out, for example, if you do that step first, does it still
> > > fail. Tracking down precisely where the problem lies is going to be
> > > helpful to anybody trying to fix/understand this problem.
>
> > > Regards,
> > > Malcolm
>
> > Yes, but the problem here is already at the level you point to.
> > Take my code version and replace
>
> > class PizzaTopping(models.Model):
> > pizza = models.ForeignKey(Pizza, core=True)
>
> > with
>
> > class PizzaTopping(models.Model):
> > pizza = models.ForeignKey(Pizza, edit_inline = models.TABULAR,
> > core=True)
>
> > and you will switch from a working version to a crappy one.
> > edit_inline = models.STACKED is no better.
> > I miss something?
>
> > I would like to add that I think that this "generalized ManyToMany" is
> > very useful, shouldn't this be mentioned in the official
> > documentation?
> > As 42th Model Example?
> > I think this is excellent during first phases of Django learning as it
> > exposes you directly to the inner functionality of the ManyToMany
> > shortcut.
>
> > Let me go even further: what about a new option for ManyToManyField
> > letting you declare the amount as seen in our Pizza-Topping example?
> > It could be really relevant when using Django for developping web-
> > based ERP and similar things.
> > Bizarre?
>
> > Giovanni.


--~--~-~--~~~---~--~~
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: Translations for 0.96

2007-06-01 Thread Jarek Zgoda

Malcolm Tredinnick napisał(a):

>> We found that one of localizations we have to use is incomplete in 0.96.
>> If we translate these texts and submit a patch, would it be included in
>> (eventual) 0.96.1 and subsequent releases of the 0.96 line?
> 
> No. The only future releases in the 0.96 line will be for security
> fixes. Any new translations will go into the next release, though.

OK, then, We'll try to include these keys in our translation.

-- 
Jarek Zgoda

"We read Knuth so you don't have to."

--~--~-~--~~~---~--~~
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: Translations for 0.96

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 10:25 +0200, Jarek Zgoda wrote:
> We found that one of localizations we have to use is incomplete in 0.96.
> If we translate these texts and submit a patch, would it be included in
> (eventual) 0.96.1 and subsequent releases of the 0.96 line?

No. The only future releases in the 0.96 line will be for security
fixes. Any new translations will go into the next release, though.

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



Serving static media, again...

2007-06-01 Thread Michal

Hello,
I have another "static media serving" question.

I understand, that separated servers are the best solution for serving 
dynamic and static (CSS, images, etc) content. But it is not possible to 
everyone.

So, I have one server with apache2+mod_python and Lighttpd installed. 
What is the best solution for serving static content?

1) serve it by Apache, from specific URL like 
http://example.com/media/image.jpg
In config I set:
[...]
   
 SetHandler None
   
[...]

2) serve it straightway by Lighhtpd on specific port, i.e. something 
like http://example.com:1234/image.jpg

3) use Apache like proxy, and serve image by Lighhtpd:
Apache conf:
[...]
   RewriteRule ^/media/(.*)$ http://127.0.0.1:8226/$1 [L,P]
[...]
Lighttpd conf:
[...]
   $SERVER["socket"] == "127.0.0.1:8226" {
 server.document-root = "/path/to/my/images"
   }
[...]

4) (something else?)

Note: I don't want to use foreign services like Amazon S3, because they 
are too far from me and there is problem in payments also.

Regards
Michal

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



Translations for 0.96

2007-06-01 Thread Jarek Zgoda

We found that one of localizations we have to use is incomplete in 0.96.
If we translate these texts and submit a patch, would it be included in
(eventual) 0.96.1 and subsequent releases of the 0.96 line?

-- 
Jarek Zgoda

"We read Knuth so you don't have to."

--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Michael Newman

I use this code in quite a few of my programs and never have issues. I
don't know why you are having this problem and it is not throwing any
errors. Are you using the Web interface at all? If so when saving are
there any errors. If the objects aren;t saving to the db generally
Python throughs some erros that can point the to the problem.
The next guess I would tell you is to use the related_name variable to
rename the foreign key so the code doesn't confuse the variables.

Malcolm is right on this one; you need to figure out exactly what is
going on before you submit a bug, because otherwise you are just
wasting the programmers' time trying to reproduce the problem. Let's
exhaust all the other possibilities first and figure out what is going
on.

Hope that helps,
Mn

On Jun 1, 3:46 am, Gio <[EMAIL PROTECTED]> wrote:
> > The usual process when you have one version of code that is working and
> > a more complicated version that is not working is to add features to the
> > working version, one at a time, until it stops working. In that way you
> > will be able to narrow down exactly which is the problematic step and
> > then work out, for example, if you do that step first, does it still
> > fail. Tracking down precisely where the problem lies is going to be
> > helpful to anybody trying to fix/understand this problem.
>
> > Regards,
> > Malcolm
>
> Yes, but the problem here is already at the level you point to.
> Take my code version and replace
>
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, core=True)
>
> with
>
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, edit_inline = models.TABULAR,
> core=True)
>
> and you will switch from a working version to a crappy one.
> edit_inline = models.STACKED is no better.
> I miss something?
>
> I would like to add that I think that this "generalized ManyToMany" is
> very useful, shouldn't this be mentioned in the official
> documentation?
> As 42th Model Example?
> I think this is excellent during first phases of Django learning as it
> exposes you directly to the inner functionality of the ManyToMany
> shortcut.
>
> Let me go even further: what about a new option for ManyToManyField
> letting you declare the amount as seen in our Pizza-Topping example?
> It could be really relevant when using Django for developping web-
> based ERP and similar things.
> Bizarre?
>
> Giovanni.


--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 07:46 +, Gio wrote:
> 
> > The usual process when you have one version of code that is working and
> > a more complicated version that is not working is to add features to the
> > working version, one at a time, until it stops working. In that way you
> > will be able to narrow down exactly which is the problematic step and
> > then work out, for example, if you do that step first, does it still
> > fail. Tracking down precisely where the problem lies is going to be
> > helpful to anybody trying to fix/understand this problem.
> >
> > Regards,
> > Malcolm
> 
> Yes, but the problem here is already at the level you point to.
> Take my code version and replace
> 
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, core=True)
> 
> with
> 
> class PizzaTopping(models.Model):
> pizza = models.ForeignKey(Pizza, edit_inline = models.TABULAR,
> core=True)
> 
> and you will switch from a working version to a crappy one.
> edit_inline = models.STACKED is no better.
> I miss something?

OK. I read your last reply and the bit you quoted from an earlier part
of the thread and there were three differences in the ForeignKey
(help_text, edit_inline and num_in_admin). I hadn't realised that wasn't
the most accurate summary of current events.

> 
> I would like to add that I think that this "generalized ManyToMany" is
> very useful, shouldn't this be mentioned in the official
> documentation?
> As 42th Model Example?

It is already documented. See model example number 9.

> I think this is excellent during first phases of Django learning as it
> exposes you directly to the inner functionality of the ManyToMany
> shortcut.

Many people would argue that being exposed to the internals of how
something works is not something they want during the first phase. Just
goes to prove (again) that different people learn in different ways and
what is easier for some people is harder for others.

> 
> Let me go even further: what about a new option for ManyToManyField
> letting you declare the amount as seen in our Pizza-Topping example?
> It could be really relevant when using Django for developping web-
> based ERP and similar things.
> Bizarre?

There's discussion on the developer's list at the moment about making it
possible to add fields to the intermediate many-to-many table that would
allow people to do things if they wanted. However, it's definitely not
something we would want to add to the ManyToManyField. It's no longer
many-to-many, then -- it's been restricted.

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



Ergonomic Mobile Computing

2007-06-01 Thread markwhite


Despite having worked with a laptop day in day out, I only landed up
with aching wrists, strained neck and back; with my work still
pending. I could quote several reasons for it - my laptop processor
runs too hot, my laptop keeps slipping from the pillow, plus the
aching back. I know most of you agree with me. Now let me share with
you the absolutely comfortable solution I found. It's called the
laptop desk which revolutionized the whole process of computing for me
with it's ergonomic design and heat dissipating ventilation channels.
I highly recommend it, check it for yourself - www.laptopdesk.net


--~--~-~--~~~---~--~~
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: Too many queries generated by ChangeManipulator

2007-06-01 Thread Gábor Farkas

Russell Keith-Magee wrote:
> On 6/1/07, char <[EMAIL PROTECTED]> wrote:
>> Obviously, the performance deteriorates rapidly as the number of
>> GamesOfInterest added to a Profile increases. Is there any way to
>> avoid this?
> 
> This is a known problem, and one of the many reasons that the forms
> framework is being replaced with 'newforms'.
> 
> There is no workaround (that I am aware of), nor are there plans to
> fix the (many) problems with the Manipulator framework.
> 
> If you are developing a new application, I _strongly_ recommend that
> you develop using newforms.
> 

it's probably still too early in the morning, but cannot this be worked 
around by using raw_id_admin?

(just a quick test where i added raw_id_admin to most of the foreignkeys 
seems to have fixed the issue (but i am not sure if you can keep all the 
other admin-options))

gabor

--~--~-~--~~~---~--~~
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: Many-to-Many with quantities

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 06:56 +, Gio wrote:
> I deleted the db and resync done, but still got the same problem.
> I add a few toppings and it works.
> I add one pizza with some toppings and their quantities: admin says
> everything is right, but really it isn't: pizza_pizzatopping is an
> empty table, while pizza_pizza got the right entry. The pizza is
> saved, his toppings aren't.
> 
> I switched to an easier version:
[...]

> And this is working, of course.

The usual process when you have one version of code that is working and
a more complicated version that is not working is to add features to the
working version, one at a time, until it stops working. In that way you
will be able to narrow down exactly which is the problematic step and
then work out, for example, if you do that step first, does it still
fail. Tracking down precisely where the problem lies is going to be
helpful to anybody trying to fix/understand this problem.

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: Many-to-Many with quantities

2007-06-01 Thread Gio

I deleted the db and resync done, but still got the same problem.
I add a few toppings and it works.
I add one pizza with some toppings and their quantities: admin says
everything is right, but really it isn't: pizza_pizzatopping is an
empty table, while pizza_pizza got the right entry. The pizza is
saved, his toppings aren't.

I switched to an easier version:

class Topping(models.Model):
name = models.CharField(maxlength=255, unique=True)

def __str__(self):
return self.name

class Admin:
pass


class Pizza(models.Model):
name = models.CharField(maxlength=255, unique=True)

def __str__(self):
return self.name

class Admin:
pass


class PizzaTopping(models.Model):
pizza = models.ForeignKey(Pizza, core=True)
topping = models.ForeignKey(Topping)
amount = models.IntegerField()

class Admin:
pass

def __str__(self):
return '%s, %i %s' % (self.pizza, self.amount, self.topping)

And this is working, of course.

I'm using the latest Django code available through subversion, I'm
suspecting a bug.
Should I file an entry in the bug tracker?

Anyone having better luck with other Django versions?

Giovanni.

On 31 Mag, 19:08, Michael Newman <[EMAIL PROTECTED]> wrote:
> Because of the dependants you might need to either manually add the
> tables to the db or if you don't have any values in that table delete
> all the rows in pizza and run syncdb again. Sometimes when working
> within the same class the syncdb doesn't change the database all the
> way (and rightly so). Give that a try and if it still doesn't work
> we'll try a different solution.
>
> On May 31, 1:03 pm, Gio <[EMAIL PROTECTED]> wrote:
>
> > Thanks to you all, I took something from all the replies and I wrote
> > this modifying Michael code:
>
> > class Topping(models.Model):
> > name = models.CharField(maxlength=255, unique=True)
>
> > def __str__(self):
> > return self.name
>
> > class Admin:
> > pass
>
> > class Pizza(models.Model):
> > name = models.CharField(maxlength=255, unique=True)
>
> > def __str__(self):
> > return self.name
>
> > class Admin:
> > pass
>
> > class PizzaTopping(models.Model):
> > pizza = models.ForeignKey(Pizza,
> >   help_text = 'Toppings to go on Pizza:
> > num in admin is how many will show up in Pizza',
> >   edit_inline = models.TABULAR,
> >   num_in_admin = 3,
> >   core=True)
> > topping = models.ForeignKey(Topping)
> > amount = models.IntegerField()
>
> > I got problems in admin: I inserted a few toppings, now when I insert
> > a new pizza with his toppings the toppings and quantities aren't
> > saved.
> > No error messages, but inspecting database reveals no entries for the
> > auxiliary table pizza_pizzatopping
>
> > Any hint?
> > I'd like to solve this problem, leaving a solution for the archives.
>
> > Thanks,
> > Giovanni.
>
> > On 31 Mag, 18:27, Michael Newman <[EMAIL PROTECTED]> wrote:
>
> > > Nis;
> > > Thanks for catching that I left the manytomany field there. There is
> > > no need for that.
> > > revised code:
>
> > > class Topping(models.Model):
> > > # ...
>
> > > class Pizza(models.Model):
> > > # ...
>
> > > class PizzaToppings(model.Model):
> > > pizza = models.ForeignKey(Pizza, help_text='Toppings to go on
> > > Pizza: num in admin is how many will show up in Pizza',
> > > edit_inline=models.TABULAR, num_in_admin=3)
> > > topping = models.ManyToOne(Topping)
> > > amount = models.IntegerField()
> > > #...
>
> > > This will appear in the Pizza part of the admin as a stacked model and
> > > allow you to use or add as many as you would like. So you can remove
> > > the amount if you just want people to be able to add double cheese by
> > > adding a second cheese topping.
>
> > > Thanks Nis and good luck Giovanni.
>
> > > Mn
>
> > > On May 31, 12:21 pm, Nis Jorgensen <[EMAIL PROTECTED]> wrote:
>
> > > > Gio wrote:
> > > > > Hi,
> > > > > I searched about this subject and found only a few very old posts, so
> > > > > maybe there is a better solution now.
>
> > > > > As you may guess the model I'd like to code is similar to the Pizza -
> > > > > Toppings you know from the "Creating Models" documentation:
>
> > > > > class Topping(models.Model):
> > > > > # ...
>
> > > > > class Pizza(models.Model):
> > > > > # ...
> > > > > toppings = models.ManyToManyField(Topping)
>
> > > > > And what if I need to say that I can have two or three times the same
> > > > > topping on my pizza? Something like twice mozzarella cheese and 3
> > > > > times green olives topping?
>
> > > > > I though about an intermediary class and indeed this is the same
> > > > > solution found in those old posts mentioned before:
>
> > > > > class Topping(models.Model):
> > > > > # ...
>
> > > > > class ToppingAndQuantity(models.Model):

Re: Guido like Django

2007-06-01 Thread Kula
django is perfect!!

On 6/1/07, Margaret <[EMAIL PROTECTED]> wrote:
>
>
> Ok, I sawed your photo.aha
>
> On 6/1/07, Kelvin Nicholson <[EMAIL PROTECTED]> wrote:
> >
> > >  In his talk he said at least 4 times that he likes
> > > Django. And I'm very excited about this.
> >
> > Thanks for telling the list about this! Being somebody interested in
> > Django, and doing business/life in China, this was great news to hear!
> >
> >
> > --
> > Kelvin Nicholson
> > Voice: +886 9 52152 336
> > Voice: +1 503 715 5535
> > GPG Keyid: 289090AC
> > Data: [EMAIL PROTECTED]
> > Skype: yj_kelvin
> > Site: http://www.kelvinism.com
> >
> >
> >
> > >
> >
>
>
> --
> [EMAIL PROTECTED]
> 13585201588
>
> >
>

--~--~-~--~~~---~--~~
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: Too many queries generated by ChangeManipulator

2007-06-01 Thread Malcolm Tredinnick

On Fri, 2007-06-01 at 10:10 +0400, Ivan Sagalaev wrote:
> Russell Keith-Magee wrote:
> > On 6/1/07, char <[EMAIL PROTECTED]> wrote:
> >> Obviously, the performance deteriorates rapidly as the number of
> >> GamesOfInterest added to a Profile increases. Is there any way to
> >> avoid this?
> > 
> > This is a known problem, and one of the many reasons that the forms
> > framework is being replaced with 'newforms'.
> > 
> > There is no workaround (that I am aware of), nor are there plans to
> > fix the (many) problems with the Manipulator framework.
> 
> Actually this bug affects both old forms and new forms. There is a 
> ticket with a patch fixing the issue: 
> http://code.djangoproject.com/ticket/3436

Ah.. that's where that patch is. I was looking for that when I saw the
earlier thread, but couldn't see it. Possibly was in the wrong component
combined with "I suck at searching".

The patch looks correct, too. I'll check it in later today (in the
middle of something else right now).

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: Too many queries generated by ChangeManipulator

2007-06-01 Thread Ivan Sagalaev

Russell Keith-Magee wrote:
> On 6/1/07, char <[EMAIL PROTECTED]> wrote:
>> Obviously, the performance deteriorates rapidly as the number of
>> GamesOfInterest added to a Profile increases. Is there any way to
>> avoid this?
> 
> This is a known problem, and one of the many reasons that the forms
> framework is being replaced with 'newforms'.
> 
> There is no workaround (that I am aware of), nor are there plans to
> fix the (many) problems with the Manipulator framework.

Actually this bug affects both old forms and new forms. There is a 
ticket with a patch fixing the issue: 
http://code.djangoproject.com/ticket/3436

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