Re: Forms, fields and widgets

2009-02-09 Thread Sergey Koval
Hello,

 I read mentioned thread and still can't figure out how I can pass arbitrary
values to widgets.
OK, I'll rephrase question (it was "task" in the previous email): how I can
make widget that takes two values out of the model without changing
ModelForm behavior or doing separate query in the widget?

 Probably it is bad mailing list to ask such questions, should I go to devel
instead?

Thanks,
Serge.

On Tue, Feb 10, 2009 at 12:21 AM, Alex Gaynor  wrote:

>
>
> On Mon, Feb 9, 2009 at 5:18 PM, Serge S. Koval wrote:
>
>>
>> Hello,
>>
>>  I'm fairly new Django user, but have some background experience with
>> other frameworks. Sorry if this topic was discussed before, but I was
>> not able to find any mention of it.
>>
>>  My question is related to architectural decisions of the forms,
>> fields and widgets.
>>
>>  At the moment in Django, all "incoming" data is processed by the
>> widget and clean by the field. Data flow: raw data -> widget -> field ->
>> form.
>>  However, reverse process is different: data -> form -> widget
>> data. As you can see, field does not play and role in reverse data
>> conversion.
>>
>>  Let's examine simple task. ModelForm calls model_to_dict() to
>> initialize form fields with initial data. In case of models data is
>> their id's.
>>  But what if one will want to develop widget that requires more
>> than just a model id? For example: str(model) and model.id at the same
>> time? There are not so many options how it can be done right now: or
>> derive from ModelForm and override it's data gathering behavior
>> (rewrite model_to_dict()) or run extra query in the widget itself (which
>> is not optimal).
>>
>>  Possible naive solution: if it would be possible to make field work in
>> _both_ directions, it would be awesome.
>>  If field will know that it works with models (like ModelForm related
>> fields), it will be responsible for cleaning data to the
>> widget-appropriate format.
>>
>>  It is my two cents. I don't know if somebody already tried to make it
>> work this way of there were some reasons not to do this way... I don't
>> know.
>>
>>  Thanks,
>> Serge.
>>
>> --
>> Best regards,
>>  Serge  mailto:serge.ko...@gmail.com
>>
>>
>>
>>
> I would recommend searching the dev list for a thread titled: "Controlling
> form/widgets output".
>
> Alex
>

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



Re: looking for working example of mptt

2009-02-09 Thread Antoni Aloy

2009/2/10 laspal :
>
> hi,
> Does anyone has a working example of django mptt. I am not able to
> implement it.
>
On the docs you have the way to go. I've followed them and it works for me.

Django-page-cms also uses it, so you can also look there.

Hope it helps
-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: including non-editable fields in forms?

2009-02-09 Thread phuong

Ramdas S wrote:
> I am looking at a solution oustide django-admin.
>
> I am in using forms and classic views
>
> Ramdas
>
> On Tue, Feb 10, 2009 at 11:28 AM, Malcolm Tredinnick 
> > wrote:
>
>
> On Tue, 2009-02-10 at 11:05 +0530, Ramdas S wrote:
> >  I think in many practical cases,
>
> s/many/some (maybe)/
>
> >  you may require permissions also to be tied in. I have a case
> where a
> > form editing rights  are tied to a some of the fields, ie employee
> > cannot edit certain fields, while managers can edit the fields in a
> > form. How do we do such cases?
>
> Admin supporting row-level permissions is entirely separate issue to
> displaying read-only fields. The latter can be solved without the
> former
> and work perfectly with existing admin. The former requires solving
> larger problems that automatically solve the read-only field case
> (since
> it has to solve permission checking for arbitrary form fields).
>
> Malcolm
>
>
>
>
>
>
>
> -- 
> Ramdas S
> +91 9342 583 065
>
>
> >
ere

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



comparisons with java framework

2009-02-09 Thread igorlash

Hi everybody.
I'm java developer , and I like comparing web frameworks.
Members of django community talk a lot about easiness of django
especially comparing with java frameworks. But they have not compared
all aspects. And I want to compare one of them.
As user of good web framework I want to have documentation on my
computer and have possibility to read it offline.
Let's compare spring framework and django.
To get spring documentation I can download spring , and this zip file
contains apis , reference manuals (in PDF and HTML formats). Or I can
visit this page http://www.springsource.org/documentation and download
PDF or view HTML online (we will not take viewing HTML online into
account , I've mentioned about it only to be honest).

And now most interesting , let take a look at django. When you
download django you have documentation in ReStructured Text format
http://docs.djangoproject.com/en/dev/faq/general/#how-can-i-download-the-django-documentation-to-read-it-offline.
This format is not very readable so I've decided to convert it to html
or something other.
I was very surprised when I found makefile in the root of doc folder.
GREAT , to read documentation offline we need to install make.But not
all python developers , especially web developers know something about
make. Ok , I've installed make. But after that I found out I need to
install one more tool Sphinx  But Sphinx requires some dependencies
and the easiest way to install them all is installing easy_install. Ok
I've installed easy_install and Sphinx but after that I've got error
about absence of some module (djangodocs).On this stage I gave up.

It's very interesting why I can't download django documentation in the
same way as I can download spring documentation or python
documentation (http://docs.python.org/download.html) ?

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



Re: including non-editable fields in forms?

2009-02-09 Thread Malcolm Tredinnick

On Tue, 2009-02-10 at 12:20 +0530, Ramdas S wrote:
>  I am looking at a solution oustide django-admin.
> 
> I am in using forms and classic views

The same answer still applies. It's really got nothing to do with
non-editable fields. It's a separate problem.

Malcolm


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



looking for working example of mptt

2009-02-09 Thread laspal

hi,
Does anyone has a working example of django mptt. I am not able to
implement it.

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



Re: including non-editable fields in forms?

2009-02-09 Thread Ramdas S
I am looking at a solution oustide django-admin.

I am in using forms and classic views

Ramdas

On Tue, Feb 10, 2009 at 11:28 AM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Tue, 2009-02-10 at 11:05 +0530, Ramdas S wrote:
> >  I think in many practical cases,
>
> s/many/some (maybe)/
>
> >  you may require permissions also to be tied in. I have a case where a
> > form editing rights  are tied to a some of the fields, ie employee
> > cannot edit certain fields, while managers can edit the fields in a
> > form. How do we do such cases?
>
> Admin supporting row-level permissions is entirely separate issue to
> displaying read-only fields. The latter can be solved without the former
> and work perfectly with existing admin. The former requires solving
> larger problems that automatically solve the read-only field case (since
> it has to solve permission checking for arbitrary form fields).
>
> Malcolm
>
>
>
> >
>


-- 
Ramdas S
+91 9342 583 065

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



Re: including non-editable fields in forms?

2009-02-09 Thread Malcolm Tredinnick

On Tue, 2009-02-10 at 11:05 +0530, Ramdas S wrote:
>  I think in many practical cases,

s/many/some (maybe)/

>  you may require permissions also to be tied in. I have a case where a
> form editing rights  are tied to a some of the fields, ie employee
> cannot edit certain fields, while managers can edit the fields in a
> form. How do we do such cases? 

Admin supporting row-level permissions is entirely separate issue to
displaying read-only fields. The latter can be solved without the former
and work perfectly with existing admin. The former requires solving
larger problems that automatically solve the read-only field case (since
it has to solve permission checking for arbitrary form fields).

Malcolm



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



Re: including non-editable fields in forms?

2009-02-09 Thread Alex Gaynor
On Tue, Feb 10, 2009 at 12:35 AM, Ramdas S  wrote:

> I think in many practical cases, you may require permissions also to be
> tied in. I have a case where a form editing rights  are tied to a some of
> the fields, ie employee cannot edit certain fields, while managers can edit
> the fields in a form. How do we do such cases?
>
> I could not find a reliable way, hence I fundamentally redirected users
> based on user types. It is kind of hacky, and ugly.
>
> Any better suggestions
>
> On Tue, Feb 10, 2009 at 10:48 AM, Malcolm Tredinnick <
> malc...@pointy-stick.com> wrote:
>
>>
>> On Mon, 2009-02-09 at 21:14 -0800, Margie wrote:
>> > I have a model that contains a 'created' field where 'editable' is set
>> > to False in the model.
>> >
>> > I'd like to display the created field in my form, but not allow it to
>> > be modified.  I tried putting it in
>> > the include list for the form, but that didn't seem to have any affect
>> > (it didn't display in the form).
>> >
>> > Is there a way to do this in a form or do I need to simply put the
>> > created field into my template separate from the display of the form?
>>
>> You could create a form Field subclass that only displays the data and
>> never validates it or inserts it into cleaned_data for the form. In
>> other words, a kind of read-only for field. There are a few details that
>> would have to be sorted out, but it sounds eminently possible if you
>> were going to do this a lot. One day we'll eventually add support for
>> read-only items in the admin and we'll have to invent something like
>> that for those, I suspect.
>>
>> On the other hand, I've always just inserted it directly into the form
>> template when I've had this kind of situation.
>>
>> Regards,
>> Malcolm
>>
>>
>>
>>
>>
>
>
> --
> Ramdas S
> +91 9342 583 065
>
>
>
> >
>
For something like you describe I would overide get_form() on ModelAdmin to
just return a different form with the correct fields.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: including non-editable fields in forms?

2009-02-09 Thread Ramdas S
I think in many practical cases, you may require permissions also to be tied
in. I have a case where a form editing rights  are tied to a some of the
fields, ie employee cannot edit certain fields, while managers can edit the
fields in a form. How do we do such cases?

I could not find a reliable way, hence I fundamentally redirected users
based on user types. It is kind of hacky, and ugly.

Any better suggestions

On Tue, Feb 10, 2009 at 10:48 AM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Mon, 2009-02-09 at 21:14 -0800, Margie wrote:
> > I have a model that contains a 'created' field where 'editable' is set
> > to False in the model.
> >
> > I'd like to display the created field in my form, but not allow it to
> > be modified.  I tried putting it in
> > the include list for the form, but that didn't seem to have any affect
> > (it didn't display in the form).
> >
> > Is there a way to do this in a form or do I need to simply put the
> > created field into my template separate from the display of the form?
>
> You could create a form Field subclass that only displays the data and
> never validates it or inserts it into cleaned_data for the form. In
> other words, a kind of read-only for field. There are a few details that
> would have to be sorted out, but it sounds eminently possible if you
> were going to do this a lot. One day we'll eventually add support for
> read-only items in the admin and we'll have to invent something like
> that for those, I suspect.
>
> On the other hand, I've always just inserted it directly into the form
> template when I've had this kind of situation.
>
> Regards,
> Malcolm
>
>
>
> >
>


-- 
Ramdas S
+91 9342 583 065

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



Re: ABC/MTI and Generic Date Based Views

2009-02-09 Thread seanbrant

Thanks I'll deal with the performance hit for now, and keep my figures
crossed :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ABC/MTI and Generic Date Based Views

2009-02-09 Thread Alex Gaynor
On Tue, Feb 10, 2009 at 12:22 AM, seanbrant  wrote:

>
> Sorry about my initial post, Im new here. I'll try harder next time ;)
>
> I choose MTI and added a entry_type field to the main Entry model.
>
> > ...(note that this could turn
> a Base.objects.all() query into O(n) queries).
>
> Is there a way out of the box to preform joins up front, when going
> from child to parent. I looked into select_related(), but that does
> not seem to be the appropriate use for it. In order to reduce the
> queries would the best option be custom views or at least a wrapper
> for the generic views?
> >
>
Ticket 7270 deals with handling the reverse relations on 1-1 fields:
http://code.djangoproject.com/ticket/7270 once that's in(and it's on the 1.1
roadmap) this should be possible out of the box.

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: ABC/MTI and Generic Date Based Views

2009-02-09 Thread seanbrant

Sorry about my initial post, Im new here. I'll try harder next time ;)

I choose MTI and added a entry_type field to the main Entry model.

> ...(note that this could turn
a Base.objects.all() query into O(n) queries).

Is there a way out of the box to preform joins up front, when going
from child to parent. I looked into select_related(), but that does
not seem to be the appropriate use for it. In order to reduce the
queries would the best option be custom views or at least a wrapper
for the generic views?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: including non-editable fields in forms?

2009-02-09 Thread Malcolm Tredinnick

On Mon, 2009-02-09 at 21:14 -0800, Margie wrote:
> I have a model that contains a 'created' field where 'editable' is set
> to False in the model.
> 
> I'd like to display the created field in my form, but not allow it to
> be modified.  I tried putting it in
> the include list for the form, but that didn't seem to have any affect
> (it didn't display in the form).
> 
> Is there a way to do this in a form or do I need to simply put the
> created field into my template separate from the display of the form?

You could create a form Field subclass that only displays the data and
never validates it or inserts it into cleaned_data for the form. In
other words, a kind of read-only for field. There are a few details that
would have to be sorted out, but it sounds eminently possible if you
were going to do this a lot. One day we'll eventually add support for
read-only items in the admin and we'll have to invent something like
that for those, I suspect.

On the other hand, I've always just inserted it directly into the form
template when I've had this kind of situation.

Regards,
Malcolm



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



Re: including non-editable fields in forms?

2009-02-09 Thread Alex Gaynor
On Tue, Feb 10, 2009 at 12:14 AM, Margie  wrote:

>
> I have a model that contains a 'created' field where 'editable' is set
> to False in the model.
>
> I'd like to display the created field in my form, but not allow it to
> be modified.  I tried putting it in
> the include list for the form, but that didn't seem to have any affect
> (it didn't display in the form).
>
> Is there a way to do this in a form or do I need to simply put the
> created field into my template separate from the display of the form?
>
> Margie
> >
>
For now you'll simply have to add it to the template.  It's a 1.1 maybe
feature to have non-editable items in the admin.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



including non-editable fields in forms?

2009-02-09 Thread Margie

I have a model that contains a 'created' field where 'editable' is set
to False in the model.

I'd like to display the created field in my form, but not allow it to
be modified.  I tried putting it in
the include list for the form, but that didn't seem to have any affect
(it didn't display in the form).

Is there a way to do this in a form or do I need to simply put the
created field into my template separate from the display of the form?

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



Looking for CTO/ Tech. Lead NY Based Startup

2009-02-09 Thread steve8004

Hello:

I'm hoping someone in the group can help identify a senior level
manager who is familiar with a CMS called Ellington and knows Django
inside and out.

Here's a more detailed description:

We're a startup offering a fun, dynamic and challenging experience
within an entrepreneurial work environment. This is an opportunity to
join the founding development team and have a key role in creating
large scale media web sites.

We're looking for a highly motivated developer who is exceptionally
bright and has experience building web applications. You love what you
do. You love to learn, to teach, and to collaborate with an agile team
in producing elegant back end and front end solutions.

We develop primarily in Python and the Django web framework on the
server side, and implement jQuery on the client side.  On the database
side we employ PostgreSQL.


For right now, the position offers equity in the company and the right
candidate will become the CTO, post funding.. We are located in New
York City.

Responsibilities
--
* Lead a team of developers in developing and maintaining our systems.
* Full life cycle development, with a focus on architecting and
developing solutions
* Work collaboratively with content producers, designers, developers,
and clients to assess business requirements and deliver the best
technology solutions.
* Monitor system stability and performance.
* Timely completion of projects.
* Produce results independently, as well as collaboratively in a team
environment.
* Write comprehensive documentation.

Skills/Qualifications
---
• Good design sense and passion for your work
* Strong Object-oriented programming knowledge
* Strong server-side web development experience using Python or Ruby
on Rails, PHP, C#, Java
• Expertise with relational database design
• Expertise with OOP javascript and javascript frameworks, especially
JQuery.
• Expertise hand-coding XHTML and CSS cross-browser
• Excellent verbal and written skills
• Strong interpersonal skills, good judgment, exceptional eye for
detail, and a positive attitude

The best candidates will have:
• Hands on experience with high volume, high availability web sites.
•Working knowledge of architectural issues that affect performance and
scalability of web sites - caching with memcache, HTTP server
experience with Apache, etc.
• Managing a team of developers, information architects, etc.
•Have prior career accomplishments with a "brand name" organization.
Media organization preferred.

Please send a cover letter and resume, highlighting your most recent
accomplishments to
cto.star...@gmail.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question about Filtering on a Related model (I think) - with example code.

2009-02-09 Thread Almost George

On the following example models (actual models, removed of cruft that
doesn't seem to apply) I'd like to add a "get_upcoming_events" method
to Band like the one on Venue, but because of the relationship I'm not
sure how to use the API/filter. (An Event has the same bands, at
possibly different occurrences, whereas each Occurrence happens at a
particular Venue - if the models/structure needed justifying).

[ code highlighted @ dpaste: http://dpaste.com/118817/ ]

class Event(models.Model):
name= models.CharField(max_length=50, unique=True)
bands   = models.ManyToManyField(Band)

class EventOccurrence(models.Model):
name= models.CharField(max_length=50, blank=True)
venue   = models.ForeignKey(Venue)
event = models.ForeignKey(Event)
start = models.DateField()
end = models.DateField()

class Band(models.Model):
admin_approved = models.BooleanField(default=False)
name = models.CharField(max_length=50, unique=True)

def get_upcoming_events(self):
# How do I get Events, where the EventOccurrence.start is
filtered
# the same as this method on the Venue model?
pass

class Venue(models.Model):
name = models.CharField(max_length=50)

def get_upcoming_events(self):
return self.eventoccurrence_set.filter
(start__gte=datetime.today())


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



Re: django admin not showing the models related data

2009-02-09 Thread Atishay



On Feb 9, 11:40 pm, Alex Gaynor  wrote:
> On Mon, Feb 9, 2009 at 11:36 PM, Atishay  wrote:
>
> > I just added admin related info in models.py
> > The models however do not show up in django admin. I am using 1.0.2
> > version currently. they were displaying properly in .97 version
>
> >  31
> >  32     def __str__(self):
> >  33         return "name: " +self.first_name + " " + self.mi + " " + \
> >  34             self.last_name + ", " + self.institution
> >  35
> >  36     class Admin:
> >  37         pass
>
> > Is the way to display information in admin different in 1.0.2
>
> 1) There is no .97 version of Django, you were probably using SVN somewhere
> between .96 and 1.0

you are absolutely correct.

> 2) Yes the admin method is very different(as is __str__)
> You can see how the new admin works 
> here:http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02
> And as for __str__ basically change it to __unicode__ and make sure it
> returns unicode(you can also use __str__ so long as you ensure that it
> returns utf-8 encoded data, more trouble that it's worth IMO).

Thank you for pointers. I created admin.py file and it works.

Regards

Atishay
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange 404 error in admin

2009-02-09 Thread Karen Tracey
On Mon, Feb 9, 2009 at 11:45 PM, Julien Phalip  wrote:

>
> On Feb 10, 3:19 pm, Karen Tracey  wrote:
> > On Mon, Feb 9, 2009 at 4:17 PM, Julien Phalip  wrote:
> > > Hello again,
> >
> > > I finally fixed it with the following nasty hack:
> >
> > > class Entry(models.Model):
> > >... some fields ...
> >
> > > objects = models.Manager() # Nasty hack
> > >published = PublishedEntryManager()
> >
> > > It seems like the 'change_state' view uses the custom manager instead
> > > of the default one. Explicitly setting 'objects' make it work. If you
> > > can think of a more elegant fix, please let me know ;)
> >
> > ? The first manager declared IS the default manager, so if the first and
> > only manager you had declared was the restrictive one, that was the
> default,
> > so that is what was used.  Declaring an unrestricted manager first, as
> you
> > have done, is the documented way to have an unrestricted default manager
> > plus one or more custom more restrictive managers.
>
> I just checked out the doc again, and I had indeed missed that part on
> the order of managers. Thank you Karen for the pointer.
>
> What I found confusing though, is that the "change list" view
> displayed *all* entries, including the unpublished ones. So that view
> supposedly didn't use the one and only, restrictive, manager that I
> had defined. As opposed to the "change object" view which apparently
> made use of that restrictive manager. In effect, the unpublished
> entries were listed but when you clicked on them you got that 404
> page. Had the unpublished entries not showed up at all (including in
> the change list) I would have thought of an issue with managers
> earlier.
>
> Because it's an old version of Django, and not even a official
> release, that might just be a bug which was then fixed at a later
> stage.
>

I have a vague recollection of trying to recreate a ticket with a
description like that.  It had been written against old admin but I could
not recreate it with newforms-admin.  So yes, I think that was a bug fixed
along the way somewhere to newforms-admin.

Karen

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



Re: Strange 404 error in admin

2009-02-09 Thread Julien Phalip

On Feb 10, 3:19 pm, Karen Tracey  wrote:
> On Mon, Feb 9, 2009 at 4:17 PM, Julien Phalip  wrote:
> > Hello again,
>
> > I finally fixed it with the following nasty hack:
>
> > class Entry(models.Model):
> >        ... some fields ...
>
> >         objects = models.Manager() # Nasty hack
> >        published = PublishedEntryManager()
>
> > It seems like the 'change_state' view uses the custom manager instead
> > of the default one. Explicitly setting 'objects' make it work. If you
> > can think of a more elegant fix, please let me know ;)
>
> ? The first manager declared IS the default manager, so if the first and
> only manager you had declared was the restrictive one, that was the default,
> so that is what was used.  Declaring an unrestricted manager first, as you
> have done, is the documented way to have an unrestricted default manager
> plus one or more custom more restrictive managers.

I just checked out the doc again, and I had indeed missed that part on
the order of managers. Thank you Karen for the pointer.

What I found confusing though, is that the "change list" view
displayed *all* entries, including the unpublished ones. So that view
supposedly didn't use the one and only, restrictive, manager that I
had defined. As opposed to the "change object" view which apparently
made use of that restrictive manager. In effect, the unpublished
entries were listed but when you clicked on them you got that 404
page. Had the unpublished entries not showed up at all (including in
the change list) I would have thought of an issue with managers
earlier.

Because it's an old version of Django, and not even a official
release, that might just be a bug which was then fixed at a later
stage.

Regards,

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



Re: django admin not showing the models related data

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 11:36 PM, Atishay  wrote:

>
> I just added admin related info in models.py
> The models however do not show up in django admin. I am using 1.0.2
> version currently. they were displaying properly in .97 version
>
>  31
>  32 def __str__(self):
>  33 return "name: " +self.first_name + " " + self.mi + " " + \
>  34 self.last_name + ", " + self.institution
>  35
>  36 class Admin:
>  37 pass
>
> Is the way to display information in admin different in 1.0.2
> >
>
1) There is no .97 version of Django, you were probably using SVN somewhere
between .96 and 1.0
2) Yes the admin method is very different(as is __str__)
You can see how the new admin works here:
http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02
And as for __str__ basically change it to __unicode__ and make sure it
returns unicode(you can also use __str__ so long as you ensure that it
returns utf-8 encoded data, more trouble that it's worth IMO).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Subclass conflict with admin widgets

2009-02-09 Thread Karen Tracey
On Mon, Feb 9, 2009 at 5:18 PM, phoebebright wrote:

>
> Yes I see that, it's just if I don't put the custom form in it works
> fine:
>
> class DirectoryAdmin(admin.ModelAdmin):
>
>
>fieldsets = [
>(None,   {'fields': ['cat','name','is_live']}),<
> CAT FIELD STILL HERE AN OK
> ('Contact', {'fields':
> ['phone','mobile','fax','email','web','address']}),
>('Details', {'fields':
> ['description','pic1','pic2','pic3','pic4']}),
>]
>
> admin.site.register(Business,DirectoryAdmin)
>

I've not looked at the admin code here to determine when it does what,
exactly, but just looking at the defs I can see what I expect is going on,
and it makes sense,  For this case, your DirectoryAdmin isn't tied a a
particular model until the admin.site.register, where you tie it to the
Business model, which has the cat field, so all in OK.  In your other case,
you had a custom form with a class Meta specifying model=Directory, which
does not have a cat field.  So your custom form does not have the field you
are trying to list in fieldsets.

There is no error in this case here because you don't do anything to tie
DirectoryAdmin to the Directory model instead of the Business model, whereas
in the error case you tie DirectoryAdmin to the Directory model, which does
not have the cat field, so you get an error.

Karen

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



django admin not showing the models related data

2009-02-09 Thread Atishay

I just added admin related info in models.py
The models however do not show up in django admin. I am using 1.0.2
version currently. they were displaying properly in .97 version

 31
 32 def __str__(self):
 33 return "name: " +self.first_name + " " + self.mi + " " + \
 34 self.last_name + ", " + self.institution
 35
 36 class Admin:
 37 pass

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



Django and jQuery trouble

2009-02-09 Thread min

Hi, everyone.

I have a question for the following example.

Firstly, in the view.py:

def test_1(request, zipcode, pro):
  if zipcode == 'a' and pro == 'b':
city = 'c'
  else:
city = ''

  return HttpResponse(city)

def test_0(request):
  return render_to_response('test_0.html', {})
-
Then, in the test_0.html




Register form


  function getZipData() {
var zipcode = $('#zip').val();
var pro = $('#pro').val();
$.get('http://127.0.0.1/ajax/test_1/' + zipcode + '&' + pro +
'/' , function(data) {
  $('#city').attr({'value':data});
});
  }





Pro:
Zip:
City:





--
In the urls.py

(r'^ajax/test_0/$', test_0),
(r'^ajax/test_1/(\S+)/$', test_1),
---
When I input b to the Pro inputbox and a to the Zip inputbox, and
click the done button, the firebug displays :500 Interserver Error

I think there are some problem with the  $.get('http://127.0.0.1/ajax/
test_1/' + zipcode + '&' + pro +  '/' , function(data) {$('#city').attr
({'value':data}); }); OR

def test_1(request, zipcode, pro):
  if zipcode == 'a' and pro == 'b':
city = 'c'
  else:
city = ''

  return HttpResponse(city)

Could you please give me some idea?

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



Re: Strange 404 error in admin

2009-02-09 Thread Karen Tracey
On Mon, Feb 9, 2009 at 4:17 PM, Julien Phalip  wrote:

> Hello again,
>
> I finally fixed it with the following nasty hack:
>
> class Entry(models.Model):
>... some fields ...
>
> objects = models.Manager() # Nasty hack
>published = PublishedEntryManager()
>
> It seems like the 'change_state' view uses the custom manager instead
> of the default one. Explicitly setting 'objects' make it work. If you
> can think of a more elegant fix, please let me know ;)
>

? The first manager declared IS the default manager, so if the first and
only manager you had declared was the restrictive one, that was the default,
so that is what was used.  Declaring an unrestricted manager first, as you
have done, is the documented way to have an unrestricted default manager
plus one or more custom more restrictive managers.

Karen

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



Re: A ManyToMany Field question.

2009-02-09 Thread khsing

Alex, thanks, now it work.

now have a new problem is may a group can contain itself, this will be a loop.

how to avoid this condition?



On Tue, Feb 10, 2009 at 11:28 AM, Alex Gaynor  wrote:
>
>
> On Mon, Feb 9, 2009 at 10:18 PM, khsing  wrote:
>>
>> I want design a group that can contain other groups, and one group can
>> belong many groups.
>>
>> I write such code below, but not right.
>>
>> class Group(models.Model):
>>groups = models.ManyToManyField(Group)
>>
>> any suggestion?
>>
>> or how to design such a group.
>>
>> thanks.
>>
>> --
>> A man live in jail and want to break.
>> http://blog.khsing.net
>>
>>
>
> To have a relationship with oneself you do
>
> ManyToManyField("self")
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>



-- 
A man live in jail and want to break.
http://blog.khsing.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: removing cached form fields

2009-02-09 Thread Louis Sayers

Ok, I'm not doing any django for the next couple of days, so will post
when I have a watered down example (unless of course doing this solves
the problem :))

On Feb 10, 4:36 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-02-09 at 17:17 -0800, Louis Sayers wrote:
> > I've got a django Form which contains a dictionary of strings. I've
> > given the form a submit button and a preview button. When the preview
> > button is pressed after entering some information, a POST is sent, and
> > the strings in the dictionary are automagically recovered (I assume
> > that it's done using session state or something). This is great,
> > exactly what I wanted.
>
> This is in no way default behaviour. So what you are doing in your
> specific code is important here. Simplify your code to a very simple
> example that demonstrates the problem and then we can see what you're
> trying to do.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: select_related(depth=5) not working in templates

2009-02-09 Thread Malcolm Tredinnick

On Mon, 2009-02-09 at 19:11 -0800, flyonthewall wrote:
> So I have this piece of code question.answer_set.select_related
> (depth=5) and the depth property doesn't work in a template so I'm
> wondering how to limit the set to only 5 items.

I think you are either not explaining what you are wanting to do very
well, or you don't understand what select_related() does. In particular,
select_related() will *never* change the results that you can access or
display (if it does, that's a bug). It is only a small optimisation for
the number of database queries executed.

If there's some kind of situation where you are trying to retrieve
objects only to a particular depth in the template -- and bear in mind
that depth=5 is effectively the default for select_related(), so you
could get away with not passing any argument in that particular case --
then you'll need to provide a method on your model or model manager to
add the appropriate select_related(depth=N) bit.

Regards,
Malcolm


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



Re: removing cached form fields

2009-02-09 Thread Malcolm Tredinnick

On Mon, 2009-02-09 at 17:17 -0800, Louis Sayers wrote:
> I've got a django Form which contains a dictionary of strings. I've
> given the form a submit button and a preview button. When the preview
> button is pressed after entering some information, a POST is sent, and
> the strings in the dictionary are automagically recovered (I assume
> that it's done using session state or something). This is great,
> exactly what I wanted.

This is in no way default behaviour. So what you are doing in your
specific code is important here. Simplify your code to a very simple
example that demonstrates the problem and then we can see what you're
trying to do.

Regards,
Malcolm



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



django is not able to load a URL

2009-02-09 Thread Atishay

Hi

I am using captcha [you would have seen my prev posts]. I have posted
code at http://dpaste.com/118796/

when I run "python manage.py runserver " I get error that django
is not able to locate a image file

[09/Feb/2009 21:23:15] "GET /captcha/captchas/cP-29Cu/
c1ba36e1391cbabc69f8db886cae3480.gif HTTP/1.1" 404 2180

the actual file location is captchas/cP-29Cu/c1ba.gif

I am not sure from where the first /captcha is being picked up. It
might be cause of I access my app is http://server:port/captcha
[ mentioned in urls.py copied at http://dpaste.com/118796/ ]

Could anyone help me figuring the problem


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



Re: A ManyToMany Field question.

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 10:18 PM, khsing  wrote:

>
> I want design a group that can contain other groups, and one group can
> belong many groups.
>
> I write such code below, but not right.
>
> class Group(models.Model):
>groups = models.ManyToManyField(Group)
>
> any suggestion?
>
> or how to design such a group.
>
> thanks.
>
> --
> A man live in jail and want to break.
> http://blog.khsing.net
>
> >
>
To have a relationship with oneself you do

ManyToManyField("self")

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: How to detect inactivity session time out?

2009-02-09 Thread Malcolm Tredinnick

On Sun, 2009-02-08 at 12:07 -0800, ydjango wrote:
> I am setting inactivity session time out using -
>  a)  request.session.set_expiry(900) and
> b)  SESSION_COOKIE_AGE = 900
> 
> I believe both work exactly the same way. Please correct me if they
> have any different behavior.
> 
> How do I detect this time out in my app and give user a page that they
> have been timed out due to inactivity.
> I am using django standard authentication using autheticate(), login()
> and logout()

You don't need to do anything like this. The browser simply won't send
the session cookie if it's too old (the session expiry time is used to
compute the cookie expiry time).

Regards,
Malcolm



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



A ManyToMany Field question.

2009-02-09 Thread khsing

I want design a group that can contain other groups, and one group can
belong many groups.

I write such code below, but not right.

class Group(models.Model):
groups = models.ManyToManyField(Group)

any suggestion?

or how to design such a group.

thanks.

-- 
A man live in jail and want to break.
http://blog.khsing.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: urlize

2009-02-09 Thread Malcolm Tredinnick

On Mon, 2009-02-09 at 07:29 -0800, Emily Rodgers wrote:
> Hi,
> 
> I have written a django app that manages 'change requests' (and
> approvals) for IT infrastructure changes in our company, and I am
> using the urlize filter when displaying certain fields (like
> description of change, test plan etc). This is so that if a user puts
> a link to documentation for a system / change then it shows up as a
> link.
> 
> This works reasonably well - in fact too well in some cases. As you
> can imagine some of the descriptions contain lists of domains, and
> these are all getting changed to links. I have logged a feature
> request for my next release of my app to sort the problem out
> (probably by wrapping lists of domain's in  tags, then
> writing a custom filter to urlize stuff that is not surrounded by
> these tags), but I was wondering if this might be something that other
> django users would want, and if so, is it worth me raising a feature
> request to get the functionality put in to the django urlize filter?

The urlize tag is designed to "urlize" anything that looks likely to be
a link. That includes domains, since they can be valid links. If it
doesn't work for your purposes, don't use it.

> 
> Or perhaps someone has a better suggestion for how to get around this
> problem?

Writing custom template tags is (by design) very easy. If any existing
tag doesn't do what you're after, or you have some other use-case that
requires special handling, then write the Python code to handle it.

It's pretty much intentional that Django doesn't handle every situation
out of the box. The universe of possibilities is too large (your example
is a case in point: you want to exclude some things that are normally
perfectly valid to be treated as URLs). Instead, we provide a lot of
ways for people to build their own extensions.

Regards,
Malcolm



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



select_related(depth=5) not working in templates

2009-02-09 Thread flyonthewall

So I have this piece of code question.answer_set.select_related
(depth=5) and the depth property doesn't work in a template so I'm
wondering how to limit the set to only 5 items.

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



Re: Question about INNER JOIN vs LEFT JOIN and some strange issue when model binds to in self through many-to-many relationship.

2009-02-09 Thread Malcolm Tredinnick

On Mon, 2009-02-09 at 06:56 -0800, AlexMVdovin wrote:
> At first step I will describe my models:
> 
> class Meter(models.Model):
> id = models.IntegerField(primary_key=True)
> 
> some stuff here...
> 
> collector = models.ManyToManyField("self",
> through='MeterCollector', symmetrical=False)
> 
> class MeterCollector(models.Model):
> meter = models.ForeignKey(Meter, related_name='meter_id')
> collector_node = models.ForeignKey(Meter,
> related_name='collecotor_node_id')
> 
> def __unicode__(self):
> return u'meter id: %s; collector node id: %s;' %
> ( self.meter_id, self.collector_node_id)
> 
> class Meta:
> db_table = 'meter_to_collector'
> 
> class MeterSspec(models.Model):
> id = models.IntegerField(primary_key=True)
> meter = models.ForeignKey(Meter)
> sspec = models.ForeignKey(Sspec)
> ..some stuff...
> 
> Everything works fine until I use filter like this in view.py:
> 
> meter_list = Meter.objects.all().filter(meter__metersspec__sspec =
> sspec_id)
> 
> I expect something like "Give me all meters that have sspec_id = 1",
> so my custom query will be:
> 
> SELECT `meter`.`id`, `meter`.`description`  FROM `meter` LEFT JOIN
> `meter_to_collector` ON (`meter`.`id` =
> `meter_to_collector`.`collector_node_id`) LEFT JOIN  `meter` T3 ON
> (`meter_to_collector`.`meter_id` = T3.`id`) INNER JOIN `meter_sspec`
> ON (`meter`.`id` = `meter_sspec`.`meter_id`) WHERE
> `meter_sspec`.`sspec_id` = '1'
> 
> But django gives me something like this:
> 
>  SELECT `meter`.`id`, `meter`.`description` FROM `meter` INNER JOIN
> `meter_to_collector` ON (`meter`.`id` =
> `meter_to_collector`.`collector_node_id`) INNER JOIN
>  `meter` T3 ON (`meter_to_collector`.`meter_id` = T3.`id`) INNER JOIN
> `meter_sspec` ON (T3.`id` = `meter_sspec`.`meter_id`) WHERE
> `meter_sspec`.`sspec_id` = '1'
> 
> There are 2 common problems:
> 1) How can I force django  to use LEFT JOIN ???

Wrong question. The real question is "why is Django using an inner join
there" and the reason is because you're filtering on a specific,
non-NULL, value on the last table. Thus, you've already ruled out the
possibility of the later tables having NULL rows in the final result.
Django is clever enough to know that this means it doesn't need to do
outer joins there. 

Since inner joins are much faster than outer ones, we optimise the join
when there's a specific non-NULL value involved.

> 2) Genreal problem: Im wondering why django joins meter_sspec with
> meter_to_collector (T3) and not with meter???

Because it's the only way to get the right answer. :-)

MeterSpec -> Meter is a many-to-one relation. So there could be multiple
MeterSpec possibilities associated with a given Meter instance. You're
asking for all those MeterSpecs that are related to a Meter that have
*a* MeterSpec associated with them that has a particular Sspec value.
The second MeterSpec instance doesn't have to be the same as the first
one in that filtering (because of the many-to-one), so we must use a new
instance of the table.

> So, is there any way to do it without custom sql query ?

Before we can give an answer, we must first know the question. What are
you trying to do?

You've given some models and some code and Django appears to be
generating the correct SQL for what you've asked in the queryset.

Apparently this isn't giving you the results you are after, so what
results are you looking for here? There's a strong possibility that your
queryset filter isn't the one you're really intending. I can't see any
problems after that point from what you've posted.

Regards,
Malcolm


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



Re: Prepoplulate admin form with previously entered data

2009-02-09 Thread Adam Woodbeck

Would it be possible to extend the ModelForm for my encounter model,
automatically filling the form when I add a new entry?

On Feb 9, 9:51 pm, Adam Woodbeck  wrote:
> I'm building my first Django app and I've run into a roadblock.  I'm
> hoping someone with more knowledge of django 1.0 can point me in the
> right direction.
>
> What the app does is allow me to enter SOAP notes for each of my daily
> patient encounters.  A good amount of the data I enter from visit to
> visit is redundant.  So I'm looking to cut down on the amount of
> typing required each time I add a new patient encounter record through
> the admin interface.  Is there any way to prepopulate a patient's
> encounter in the admin interface using data from the patient's
> previous encounter?
>
> Adam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with set_language generic view

2009-02-09 Thread Malcolm Tredinnick

On Sun, 2009-02-08 at 20:34 -0800, yav wrote:
> Hello,
> 
> I have a problem with the generic view set_language. I used it but it
> doesn't change the language. I have read the doc but I didn't find
> what is the problem. I have read the doc but I didn't find what is the
> problem. I have setup an empty project in order test it with a very
> simple example. Here is my config: http://dpaste.com/hold/118420/.

In passing, I'll note that that is a very fragile HTML form. If somebody
accidentally releases the mouse button before getting to the language
they were after, it will submit whatever the selection drop down
happened to have selected. Hope the user can read Arabic if that's what
they accidentally selected so that they can go back and fix the
accidental mouse-error!

That's why forms tend to operate with a "select value, then confirm"
paradigm for things that can have a bad effect on the UI.

> 
> I'm working with the latest svn version. I tested the application with
> Safari and Firefox and with Apache and the development server, but it
> doesn't work anyway.

Well, you can probably assume set_language works fairly well. It's
another one of those functions that, if we broke it, we'd hear about it
immediately, since a large portion of the multilingual websites using
Django use it, or something very similar. You are, however, using it
slightly differently from normal by doing a Javascript submission of the
form.

So check if the form really is being submitted -- does the set_language
view get called (Just drop a debugging print into the view to see if it
is called)? What happens if you remove the Javascript stuff and just
include a normal submit button for the form? Does it work then (if so,
you know the Javascript bit is somehow not working, for example)?

Regards,
Malcolm


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



Prepoplulate admin form with previously entered data

2009-02-09 Thread Adam Woodbeck

I'm building my first Django app and I've run into a roadblock.  I'm
hoping someone with more knowledge of django 1.0 can point me in the
right direction.

What the app does is allow me to enter SOAP notes for each of my daily
patient encounters.  A good amount of the data I enter from visit to
visit is redundant.  So I'm looking to cut down on the amount of
typing required each time I add a new patient encounter record through
the admin interface.  Is there any way to prepopulate a patient's
encounter in the admin interface using data from the patient's
previous encounter?

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



Re: pre-populating multiplechoicefields with session data

2009-02-09 Thread Malcolm Tredinnick

On Sun, 2009-02-08 at 09:57 -0800, Bobby Roberts wrote:
> Hi group.  Please look at this view:
> 
> # this form runs the search mechanism
> def DoSearchForm (request):
> if request.method =='POST':
> form=SearchForm (request.POST)
> if form.is_valid():
> try:
> myuid=request.user.id * 1
> except:
> myuid=0
> #form submitted passes validation so submit to database as
> a valid search term record
> mydata = SearchAttempt (
> Terms = CleanMe(request.POST.get('Terms','')),
> suid = myuid
> )
> mydata.save()   #save to sarch_attempt table
> # save items to session variables
> request.session["Terms"]=request.POST.get('Terms','')
> request.session["Iforand"]=request.POST.get('Iforand','')
> request.session["Programelement"]=request.POST.get
> ('Programelement','')
> request.session["Disaster"]=request.POST.get
> ('Disaster','')
> request.session["Submissionmethod"]=request.POST.get
> ('Submissionmethod','')
> 
> return HttpResponseRedirect('/search/results/')
> else:
> return render_to_response('submit-search.html', {'form':
> form}, context_instance=RequestContext(request))
> else:# load form for first time
> if 'Terms' in request.session:
> form = SearchForm(initial={'Terms':request.session
> ['Terms'],'Iforand':request.session
> ['Iforand'],'Programelement':request.session
> ['Programelement'],'Disaster':request.session
> ['Disaster'],'Submissionmethod':request.session['Submissionmethod']})
> else:
> form = SearchForm(initial={'Iforand':'exact'})
> return render_to_response('submit-search.html', {'form':
> form}, context_instance=RequestContext(request))
> 
> 
> This view is working perfectly except for one thing.  If someone
> completes the form, it saves the form options to a session and inserts
> the term they searched for into the database.  If they close their
> browser and come back to the search form, I want their previous
> choices to populate the form again.  Terms and Iforand populate as
> they should.  Programelement, Disaster, and Submissionmethod are all
> multiplechoicefield textbox lists and none of the previously selected
> options are selected.  Can you see what i'm doing wrong?

The request.POST object is a QueryDict, which is a subclass of
MultiValueDict. If you want to retrieve *all* the values for a
particular key, you need to use getlist(), not get(). See the
documentation for more details (in particular, getlist() is in the
index).

Also, please wait more than a mere 8 hours before posting a "help me
faster!" message. You are only one of a few hundred messages per day to
this list. If nobody has responded after three days or so, maybe a quiet
ping request might be appropriate. But not after only a few hours
(particularly when you remember that the world has timezones and many
people are no doubt asleep for that entire eight hour period).

Regards,
Malcolm



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



Re: ABC/MTI and Generic Date Based Views

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 9:11 PM, Malcolm Tredinnick  wrote:

>
> On Sat, 2009-02-07 at 12:40 -0800, seanbrant wrote:
> > Im have troubling figuring about a good solution for blog posts. I
> > have created a ABC called Entry which Post, Link, Photo, Quote
> > inherit.
>
> It would help others to define a few terms here before leaping into the
> acronyms: ABC = "abstract base class", MTI = "multi-table inheritance",
> I'm guessing.
>
> >
> > I first tired it with MTI and set Entry.objects.all() as the queryset
> > attribute. This will pass the list of Entry's to the template which I
> > can iterate over. However I would like to style each type of Entry
> > object a little different. Is there a way to know which type of Entry
> > you are dealing with.
>
> Yes, by adding a field called "child_type" or something similar and
> noting the content type of the most derived child, for example.
>
> > Then I tried ABC with the same models. Obviously including abstract
> > True to the Base Entry class. With this approach I have know idea  how
> > to get a query set for all of these objects.
>
> You can't. They different types aren't related to each other. You need
> to make "N" querysets and write your own version of the generic view
> (remember, generic views are just an aid -- they don't fit all
> requirements and not using them is always an option).
>
> > This seems like a fairly common use-case,
>
> Which is why it's been answered a number of times in the past. :-)
>
> Malcolm
>
>
> >
>
If you choose to work with MTI I've worked up a bit of code that will
automatically denormalize which subclass on object is, and load up the
correct one when something is fetched from the ORM(note that this could turn
a Base.objects.all() query into O(n) queries).  In any event here is the
code: http://dpaste.com/118723/ I plan to write up a proper blog post on it
later at some point.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Extending the User model

2009-02-09 Thread Malcolm Tredinnick

On Sun, 2009-02-08 at 12:16 -0800, Patricio Palma wrote:
> Greetings
> 
> I've a model
> class MyUser(auth.User):
> location = meta.CharField(maxlength=100, blank=True)
> 
> class META:
> replaces_module = 'auth.users'
> admin = meta.Admin(
> list_display = ('username', 'email',
> 'first_name','last_name', 'lacation')
> )

Django hasn't used that syntax since the 0.91 release. Since then, admin
has been through two major revisions.

What version of Django are you using (keeping in mind that if you are
using 0.91, you're going to be pretty much on your own with solving most
problems, since it's from so long and so many changes ago)?

If you're using, say, Django 1.0, the documentation is your friend as to
the right syntax for the admin interface.

Regards,
Malcolm



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



Re: Memory Leaks

2009-02-09 Thread Malcolm Tredinnick

On Sat, 2009-02-07 at 19:27 -0800, python6009 wrote:
> Hi,
> 
> I am using matplotlib/pyplot on my site to dynamically generate PNG
> plots. And I am experiencing dramatic memory leaks. Within 10-15
> hits,  my Apache process grows from 15-20M to 100M.

Let's be accurate with the terminology here, please. Nothing in your
description suggests you have a memory leak. It suggests that you have
memory *usage*, but that's not the same thing. A leak is when something
reserves some memory and never returns it to the general pool. And you
haven't shown that that is happening here.

If you need 100M to process the image, then it's likely that the Apache
process that is doing that work will grow to 100M. The way malloc() and
free() work in Unix, too, means that if 100M is reserved by Apache via
malloc(), a subsequent free() call will let Apache reuse that memory,
but won't return it to the system until the process terminates -- which
happens regularly with Apache children, so it's only a transient usage.

Make sure you approach this with the right debugging attitude: you're
initially trying to discover what is *using* the memory.

Regards,
Malcolm



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



problems with django+fastcgi

2009-02-09 Thread Rodrigo Lazo

Hi everybody,

I'm hosting my blog on asmallorange.com, and I've been having problems with
my blog from the beginning, it takes too much to load the page and when
access to my account using ssh I get that too many processes are
running. I'm using fastcgi.

I found that my error log is plagued with messages like this (wrapped
by me)

[Mon Feb  9 20:47:43 2009] [warn] FastCGI: (dynamic) 
 server "/home/mauricio/public_html/engine.fcgi" 
 (uid 32282, gid 32284) restarted (pid 13006)
[Mon Feb  9 20:47:40 2009] [warn] FastCGI: (dynamic) 
 server "/home/mauricio/public_html/engine.fcgi" 
 (pid 12520) terminated by calling exit with status '0'
[Mon Feb  9 20:47:39 2009] [warn] FastCGI: 
 (dynamic) server "/home/mauricio/public_html/engine.fcgi" 
 (pid 12520) termination signaled
[Mon Feb  9 20:45:02 2009] [warn] FastCGI: 
 (dynamic) server "/home/mauricio/public_html/engine.fcgi" 
 (pid 11933) terminated by calling exit with status '0'
[Mon Feb  9 20:45:02 2009] [warn] FastCGI: 
 (dynamic) server "/home/mauricio/public_html/engine.fcgi" 
 (uid 32282, gid 32284) restarted (pid 12520)
[Mon Feb  9 20:45:02 2009] [warn] FastCGI: 
 restarting old server "/home/mauricio/public_html/engine.fcgi" 
 processes, newer version found

More than 300 of this messages just today! So there is something that i
must be doing wrong to have this processes restarting and terminating so
often.

Any ideas what is causing this??

here is my script

, engine.fcgi
| #!/bin/env python
| import sys, os
| 
| 
| sys.path += ['/home/mauricio/local/lib/python2.4/site-packages',
|
'/home/mauricio/local/lib/python2.4/site-packages/dateutil-1.2-py2.4.egg',
|
'/home/mauricio/local/lib/python2.4/site-packages/Pygments-0.10-py2.4.egg',
|  '/home/mauricio/django-projects',
|  '/home/mauricio/django-projects/website/']
| 
| # Switch to the directory of your project. (Optional.)
| os.chdir("/home/mauricio/django-projects/website/")
| 
| # Set the DJANGO_SETTINGS_MODULE environment variable.
| os.environ['DJANGO_SETTINGS_MODULE'] = "website.settings"
| 
| 
| from django.core.servers.fastcgi import runfastcgi
| runfastcgi(method="threaded", daemonize="false")
`

and my .htaccess

, .htaccess
| AddHandler fastcgi-script .fcgi
| RewriteEngine On
| RewriteCond %{REQUEST_FILENAME} !-f
| RewriteRule ^(.*)$ engine.fcgi/$1 [QSA,L]
`

-- 

Rodrigo Lazo (rlazo)


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



Re: ABC/MTI and Generic Date Based Views

2009-02-09 Thread Malcolm Tredinnick

On Sat, 2009-02-07 at 12:40 -0800, seanbrant wrote:
> Im have troubling figuring about a good solution for blog posts. I
> have created a ABC called Entry which Post, Link, Photo, Quote
> inherit.

It would help others to define a few terms here before leaping into the
acronyms: ABC = "abstract base class", MTI = "multi-table inheritance",
I'm guessing.

> 
> I first tired it with MTI and set Entry.objects.all() as the queryset
> attribute. This will pass the list of Entry's to the template which I
> can iterate over. However I would like to style each type of Entry
> object a little different. Is there a way to know which type of Entry
> you are dealing with.

Yes, by adding a field called "child_type" or something similar and
noting the content type of the most derived child, for example.

> Then I tried ABC with the same models. Obviously including abstract
> True to the Base Entry class. With this approach I have know idea  how
> to get a query set for all of these objects.

You can't. They different types aren't related to each other. You need
to make "N" querysets and write your own version of the generic view
(remember, generic views are just an aid -- they don't fit all
requirements and not using them is always an option).

> This seems like a fairly common use-case,

Which is why it's been answered a number of times in the past. :-)

Malcolm


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



WeakForeignKey - on delete set null rather than delete me

2009-02-09 Thread felix
that old "django deleted my object!" thing
plus solution (at bottom)

class Venue(models.Model):
pass

class Event(models.Model):
venue =
models.ForeignKey(Venue,related_name='venue',blank=True,null=True)

v = Venue.objects.create()
e = Event.objects.create(venue=v)
v.delete()

the Event e is now deleted from the db
any model with a ForeignKey will be deleted with the model it points to is
deleted.
which is exactly what ForeignKeys are supposed to do

but my desired behavior here is to set:  e.venue = None
aka ON DELETE SET NULL

its a weak relationship

btw. this is not the solution, to flip it around:

class Venue(models.Model):
events = models.ManyToManyField(Event,blank=True)

because in actual practice there are many ForeignKeys pointing to models in
different apps
and it would be horribly polluting to put ManyToManyFields in all of those.
in these cases these are more like attributes or extra information.
(tho in most cases ForeignKey is correct behavior)


but the best solution I think is to write a :

class WeakForeignKey(ForeignKey):
"""which can only be blank=True/null=True 
...

class WeakManyToOneRel(ManyToOneRel):
pass


django.db.models.base

def _collect_sub_objects(self, seen_objs, parent=None, nullable=False):
...
if isinstance(related.field.rel, OneToOneRel):
...
elif isinstance(related.field.rel,WeakManyToOneRel):
for sub_obj in getattr(self, rel_opts_name).all():
setattr(sub_obj,related.field.name,None)
sub_obj.save()
else:
...


class Event(models.Model):
venue = models.WeakForeignKey(Venue)


which I did, it works, test written etc.

comments ?  prior art that I didn't find ?
easier solutions ?
naming advice ?

I'll happily write up a ticket and patch




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



Re: unable to import imaging c module

2009-02-09 Thread Atishay

On Feb 9, 7:11 pm, Atishay  wrote:
> hi
>
> i am trying to use PIL, with Django to display Captcha. This could be
> newbie stuff as I am new to python and PIL.
>
> I am getting following error when importing ImageFont.
>
> ImportError: The _imaging C module is not installed

I was able to "import ImageFont" if I do following.

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

Now I do "python manage.py shell" and "import ImageFont" and it works.

Now, how can we ensure that Django always sets LD_LIBRARY_PATH so that
import does not fail?

Did I solve it in right manner? Is there a better way.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Several 'virtual' fields controlled by an unique custom field ?

2009-02-09 Thread Alexandre Vaissiere

Hello,

I have a model that looks like this :

class Entry(models.Model):
data = models.TextField()
data_html = models.TextField(editable=False)

def save(self):
self.data_html = convert(self.data)
super(Entry, self).save()

It works fine, but an exception raised by convert function would lead to
a 500 response. So I pondered myself, and came back with a custom field
and its associated form field:

class CustomTextField(TextField):
def __init__(self, *args, **kwargs):
super(CustomTextField, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
defaults = {'form_class': CustomTextFormField}
defaults.update(kwargs)
return super(CustomTextField, self).formfield(**defaults)

class CustomTextFormField(forms.CharField):
def clean(self, value):
value = super(CustomTextFormField, self).clean(value)
try:
convert(value)
except Exception, e:
raise forms.ValidationError(e.message)
return value

Now, it works really fine, I have a pretty error message when i make
some mistake during edition. Still I see two problems:

 * The convert() process is done twice,
 * If i want to reuse my CustomTextField elsewhere, i will need to
override the Model.save() method in every model.

My idea is that CustomTextField should manage under the hood two model
fields: data and data_html, taking off the burden of declaring and
managing this from the model.

Unfortunately I have no idea how to achieve this.

Ideally, my model would look like this:

class Entry(models.Model):
data = CustomTextField()
   
>>> convert(u'flying')
u'flying'
>>> e = Entry()
>>> e.data = u'flying'
>>> e.data_html
u'flying'

select * from app.entry;
|| id || data   || data_html ||
|| 1  || flying || flying ||

Does someone have some link or idea how doing that ? I failed to find it
in the documentation (or more probably failed to properly understand it).

Thank you in advance,

Kind regards,
Alexandre.


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



removing cached form fields

2009-02-09 Thread Louis Sayers

I've got a django Form which contains a dictionary of strings. I've
given the form a submit button and a preview button. When the preview
button is pressed after entering some information, a POST is sent, and
the strings in the dictionary are automagically recovered (I assume
that it's done using session state or something). This is great,
exactly what I wanted.

The problem is that if I don't submit the form, then do a GET (i.e.
browse to the page with the form on it), enter some info and hit
preview, the information that was stored in the dictionary from the
first preview is still there.

How do you clear this information?

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



unable to import imaging c module

2009-02-09 Thread Atishay

hi

i am trying to use PIL, with Django to display Captcha. This could be
newbie stuff as I am new to python and PIL.

I am getting following error when importing ImageFont.

ImportError: The _imaging C module is not installed

I have the file though.

[bash]# file PIL/_imaging.so

PIL/_imaging.so: ELF 32-bit LSB shared object, Intel 80386, version 1
(SYSV), not stripped

How could I fix this?

I am able to import other stuff like Image, ImageDraw, ImageColor


How can I find out version of PIL?


Regards

Atishay



Captcha module being used : http://django.agami.at/media/captcha/



=details
>>> import ImageFont
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.5/site-packages/PIL/ImageFont.py", line
115, in 
class FreeTypeFont:
  File "/usr/local/lib/python2.5/site-packages/PIL/ImageFont.py", line
135, in FreeTypeFont
def getmask2(self, text, mode="", fill=Image.core.fill):
  File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 36,
in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed



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



Pretty admin pages

2009-02-09 Thread djandrow

Hello all,

I have just set up the admin pages for my site and if i use the built
in server i get the admin with the nice templates, but if I display it
on mod_python I just get the plain text, which is pretty hard to work
with.

I have these set up in the conf:


SetHandler None



SetHandler None


and my setting py has:

MEDIA_ROOT = ''
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/media/'

what am i doing wrong or what have i missed?

on a side note should i add CSS to my jpg|gif|png in my conf?

many thanks,

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



Re: How to handle an error that throws an alert box and make it show an AJAX error message instead?

2009-02-09 Thread Matías Costa
I love lightboxes

http://particletree.com/features/lightbox-gone-wild/

If you enable the auth middleware you can do:

{% if user.is_authenticated %}

{% else %}

{% endif %}

or in the view return a 400 forbidden and just in javascript (jquery code):

$.ajax({
  url:"do_vote_url",
  success: show_ok,
  error: show_error
});

and implement these 2 js functions.

On Tue, Feb 10, 2009 at 12:49 AM, Shantp  wrote:

>
> I'm using Django and django-voting in an app I'm making. If a user who
> is not authenticated tries to vote, an alert box is displayed telling
> them they are not authenicated. How can I catch this error and make it
> into a more elegant AJAX display so I can show it right on the page
> when it happens?
> >
>

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



Re: Keep getting NameError at /admin/

2009-02-09 Thread djandrow

You need to remove the # from:

# from django.contrib import admin
# admin.autodiscover()

I had the same thing earlier.

Heres some more stuff about setting up the admin if you want to read
it:

http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02

On Feb 9, 11:24 pm, "claudio.br...@googlemail.com"
 wrote:
> On 9 Feb, 19:16, Daniel Roseman  wrote:
>
> > On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
>
> >  wrote:
> > > Hi Alex
>
> > > Yes I have the line from django.contrib import admin" in urls.py
>
> > You're going to need to post the whole urls.py. It's a bit hard to
> > understand why you're getting that error if you do have that line, and
> > it's not commented out. Please show us the whole file, preferably by
> > posting it somewhere like dpaste.com.
>
> > --
> > DR.
>
> Okay I stripped everything else out of the urls.py and am left with
> the following
>
> ---
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
>     # Example:
>     # (r'^mysite/', include('mysite.foo.urls')),
>
>     # Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
>     # to INSTALLED_APPS to enable admin documentation:
>     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>     # Uncomment the next line to enable the admin:
>      (r'^admin/(.*)', admin.site.root),
> )
>
> and I still get the same error
>
> K
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 6:24 PM, claudio.br...@googlemail.com <
claudio.br...@googlemail.com> wrote:

>
>
>
> On 9 Feb, 19:16, Daniel Roseman  wrote:
> > On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
> >
> >  wrote:
> > > Hi Alex
> >
> > > Yes I have the line from django.contrib import admin" in urls.py
> >
> > You're going to need to post the whole urls.py. It's a bit hard to
> > understand why you're getting that error if you do have that line, and
> > it's not commented out. Please show us the whole file, preferably by
> > posting it somewhere like dpaste.com.
> >
> > --
> > DR.
>
> Okay I stripped everything else out of the urls.py and am left with
> the following
>
> ---
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^mysite/', include('mysite.foo.urls')),
>
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
># Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> )
>
> and I still get the same error
>
> K
>
> >
>
You have the import commented out, this means that code never gets
executed.  I would recommend reading up a bit more on python before
proceeding.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



How to handle an error that throws an alert box and make it show an AJAX error message instead?

2009-02-09 Thread Shantp

I'm using Django and django-voting in an app I'm making. If a user who
is not authenticated tries to vote, an alert box is displayed telling
them they are not authenicated. How can I catch this error and make it
into a more elegant AJAX display so I can show it right on the page
when it happens?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread claudio.br...@googlemail.com



On 9 Feb, 19:16, Daniel Roseman  wrote:
> On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
>
>  wrote:
> > Hi Alex
>
> > Yes I have the line from django.contrib import admin" in urls.py
>
> You're going to need to post the whole urls.py. It's a bit hard to
> understand why you're getting that error if you do have that line, and
> it's not commented out. Please show us the whole file, preferably by
> posting it somewhere like dpaste.com.
>
> --
> DR.

Okay I stripped everything else out of the urls.py and am left with
the following

---

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
 (r'^admin/(.*)', admin.site.root),
)

and I still get the same error

K

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



Re: python manage.py runserver giving strange error

2009-02-09 Thread Arnaud Delobelle

I've avoided the problem by using django-admin instead of
manage.py...  Which does not tell me what's gone wrong.

--
Arnaud


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



Re: Exception in Django's Exception Handling

2009-02-09 Thread Russell Keith-Magee

On Tue, Feb 10, 2009 at 1:59 AM, Devel63  wrote:
>
> I'll see if I can extract some small subset and post the details.
>
> In the meantime, more info: the problem only occurs when an error is
> encountered during a call in which the server will return a
> HttpResponse('', mimetype='text/xml; charset=utf-8') object in
> response to some AJAX request; things apparently work when the server
> will return a render_to_response, which shows a page in the browser.
>
> Before I switched to Django, and just used webapp (a simplified
> version of Django in Google App Engine), the first type of problem
> would dump the stack trace to the console.  Now, the trace does not go
> to the console, and it is here that the exception within the exception
> is thrown.
>
> Could this be a setting or path issue?

It _could_ be many things. However, unless you give us details, we
can't give you details. So far, you haven't even told us the
exceptions you are seeing. In the absence of details, we would only be
guessing, and given that none of us have seen this problem before, it
wouldn't be a particularly educated guess.

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



YUI Image Uploader - OK on Firefox/Mac but not elsewhere

2009-02-09 Thread phoebebright

Have been trying to get a RTE plugin working that will allow upload of
images.  The YUI verion is almost there but will not play well with
browsers.

The plugin from here 
http://allmybrain.com/2008/11/06/example-yui-image-upload-with-yui-260/
I modified to get Javascript to make an asynchronous call to this
function in the view:

def uploadimage(request):
try:
upload_full_path = settings.CONTENT_IMAGES

upload = request.FILES['image']
dest = open(os.path.join(upload_full_path, upload.name), 'wb+')

for chunk in upload.chunks():
dest.write(chunk)

dest.close()

result='{status:"UPLOADED",image_url:"%s%s"}' %
(settings.CONTENT_IMAGES_URL, upload.name)

return_data = HttpResponse(result,mimetype='Content-Type: text/
html')

except Exception, e:
return_data = HttpResponse("Error in uploading image")

return_data.flush()

return return_data

The plugin was written for turbon gears/php and there is a tg example
here:

http://allmybrain.com/2007/10/22/yui-image-uploader-example-with-turbogears/

Firefox/Mac works perfectly.  Safari downloads the image instead.  No
version on PC appears to do anything, (but only have Mac for local
testing.)
Have tried every possible permutation of the content-type, Content-
Type and text/html definitely is the way to go.  Various threads on
python refer to the need to open the file for reading as rb to make
sure windows knows it is binary, but not sure how to do that as the
response data is already in memory.

In desperation I have also tried to implement image upload in TinyMCE
- can't get FileBrowser working on PC.  and FCKeditor no modifiable
image upload that I could find.  So I am back with YUI and hoping
someone can suggest something to try
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re[2]: Forms, fields and widgets

2009-02-09 Thread Serge S. Koval





Hello Alex,

Tuesday, February 10, 2009, 12:21:05 AM, you wrote:




>


I would recommend searching the dev list for a thread titled: "Controlling form/widgets output".

Alex




 Thanks, I was looking in django-users list and this topic was django-devel.

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





using the ImageField with the API

2009-02-09 Thread redmonkey

Hey everyone,

I've got an interesting problem concerning file uploads.

I'm building an online auction and my `Lot` links to a thin
`LotImage` so that I can store multiple images of the lots:

class Lot(models.Model):
...
lot_number = models.PositiveIntegerField("Lot number")

Class LotImage(models.Model)
...
lot = models.ForeignKey(Lot, related_name="images")
main_image = models.ImageField(upload_to=get_main_image_path)

you can see I've written a callable for the `upload_to` parameter
because I want to store the images in a particular place:

def get_thumbnail_path(instance, filename):
return os.path.join(
LotImage.BASE_PATH,
instance.lot.catalogue.__unicode__(),
filename
)

This is all good and works a treat in the admin UI, but how can I keep
this `upload_to` functionality when working with the API by hand?

Django's Documentation on the subject talks about the `File` class
(http://docs.djangoproject.com/en/dev/topics/files/#the-file-object)
which works fine when you explicitly create LotImages:

f = open('/tmp/hello.world', 'w')
myfile = File(f)
f.close()

LotImage.create(
lot_id = 1,
main_image = myfile
)

But by doing so, I loose the `upload_to` functionality. How can I keep
it without physically moving the file to the right place, then
creating a File object and attaching to a new LotImage?

I basically want to create exactly what the admin UI does with
uploaded files.

Can anyone help?

Thanks,

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



Re: Forms, fields and widgets

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 5:18 PM, Serge S. Koval wrote:

>
> Hello,
>
>  I'm fairly new Django user, but have some background experience with
> other frameworks. Sorry if this topic was discussed before, but I was
> not able to find any mention of it.
>
>  My question is related to architectural decisions of the forms,
> fields and widgets.
>
>  At the moment in Django, all "incoming" data is processed by the
> widget and clean by the field. Data flow: raw data -> widget -> field ->
> form.
>  However, reverse process is different: data -> form -> widget
> data. As you can see, field does not play and role in reverse data
> conversion.
>
>  Let's examine simple task. ModelForm calls model_to_dict() to
> initialize form fields with initial data. In case of models data is
> their id's.
>  But what if one will want to develop widget that requires more
> than just a model id? For example: str(model) and model.id at the same
> time? There are not so many options how it can be done right now: or
> derive from ModelForm and override it's data gathering behavior
> (rewrite model_to_dict()) or run extra query in the widget itself (which
> is not optimal).
>
>  Possible naive solution: if it would be possible to make field work in
> _both_ directions, it would be awesome.
>  If field will know that it works with models (like ModelForm related
> fields), it will be responsible for cleaning data to the
> widget-appropriate format.
>
>  It is my two cents. I don't know if somebody already tried to make it
> work this way of there were some reasons not to do this way... I don't
> know.
>
>  Thanks,
> Serge.
>
> --
> Best regards,
>  Serge  mailto:serge.ko...@gmail.com
>
>
> >
>
I would recommend searching the dev list for a thread titled: "Controlling
form/widgets output".

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Forms, fields and widgets

2009-02-09 Thread Serge S. Koval

Hello,

 I'm fairly new Django user, but have some background experience with
other frameworks. Sorry if this topic was discussed before, but I was
not able to find any mention of it.

 My question is related to architectural decisions of the forms,
fields and widgets.

 At the moment in Django, all "incoming" data is processed by the
widget and clean by the field. Data flow: raw data -> widget -> field ->
form.
 However, reverse process is different: data -> form -> widget
data. As you can see, field does not play and role in reverse data
conversion.

 Let's examine simple task. ModelForm calls model_to_dict() to
initialize form fields with initial data. In case of models data is
their id's.
 But what if one will want to develop widget that requires more
than just a model id? For example: str(model) and model.id at the same
time? There are not so many options how it can be done right now: or
derive from ModelForm and override it's data gathering behavior
(rewrite model_to_dict()) or run extra query in the widget itself (which
is not optimal).

 Possible naive solution: if it would be possible to make field work in
_both_ directions, it would be awesome.
 If field will know that it works with models (like ModelForm related
fields), it will be responsible for cleaning data to the
widget-appropriate format.

 It is my two cents. I don't know if somebody already tried to make it
work this way of there were some reasons not to do this way... I don't
know.

 Thanks,
Serge.

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



Re: Subclass conflict with admin widgets

2009-02-09 Thread phoebebright

Yes I see that, it's just if I don't put the custom form in it works
fine:

class DirectoryAdmin(admin.ModelAdmin):


fieldsets = [
(None,   {'fields': ['cat','name','is_live']}),<
CAT FIELD STILL HERE AN OK
('Contact', {'fields':
['phone','mobile','fax','email','web','address']}),
('Details', {'fields':
['description','pic1','pic2','pic3','pic4']}),
]

admin.site.register(Business,DirectoryAdmin)

 It suggest to me there is something in the admin code which normally
allows for this 'error' to pass.  It's not a big deal, I just wondered
if it was somthing django should allow for and the design of the two
examples is inherantly the same.


On Feb 9, 8:52 pm, Daniel Roseman 
wrote:
> On Feb 9, 7:28 pm, phoebebright  wrote:
>
>
>
> > I have implemented this solution successfully with a standard model,
> > but when I try to use it on one which is subclassed I get an error
> > because it is trying to validate the model before it knows about the
> > subclass.  I can work around this by defining an Admin class for each
> > of the subclasses, but it seems to me this should work?
>
> > Model.py
>
> > class Directory(models.Model):
> >     name = models.CharField(max_length=60)
> >     pic1 = models.ImageField(upload_to='pics', blank=True,
> > null=True)
>
> > class Business(Directory):
> >     cat = models.ForeignKey(Subcategory)
>
> > Admin.py
>
> > AdminImageWidget defined 
>
> > class DirectoryAdminForm(forms.ModelForm):
> >     pic1 = forms.ImageField(widget=AdminImageWidget())
>
> >     class Meta:
> >         model = Directory
>
> > class DirectoryAdmin(admin.ModelAdmin):
>
> >     form = DirectoryAdminForm
>
> >     fieldsets = [
> >         (None,   {'fields': ['cat','name','is_live']}),    <
> > CAT FIELD IS PART OF BUSINESS NOT DIRECTORY SO CAUSES ERROR
> >         ('Contact', {'fields':
> > ['phone','mobile','fax','email','web','address']}),
> >         ('Details', {'fields':
> > ['description','pic1','pic2','pic3','pic4']}),
> >     ]
>
> > admin.site.register(Business,DirectoryAdmin)
>
> > Error
>
> > ImproperlyConfigured at /admin/town/business/14/
>
> > 'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
> > is missing from the form.
>
> The error message tells you what is going on. Your form definition has
> model=Directory in its Meta class, so it only contains fields from the
> Directory model. If you want it to contain the fields from the
> subclassed Business model, you'll need to change that Meta
> declaration.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



python manage.py runserver giving strange error

2009-02-09 Thread Arnaud Delobelle

Hello django users,

Today I have had this strange error: after a syntax error in a module
I had to restart my development server.

marigold:qmm arno$ python manage.py runserver
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python: can't open file 'manage.py': [Errno
2] No such file or directory

All of a sudden, Python pretends not to be able to see manage.py!
But manage.py is present and what's more:

marigold:qmm arno$ python manage.py
Type 'manage.py help' for usage.
marigold:qmm arno$ python manage.py help runserver
Usage: manage.py runserver [options] [optional port number, or
ipaddr:port]

Starts a lightweight Web server for development.
[...]

What's going on?  I have no idea where to start looking, I am not even
sure it's django related (although I have not found any other problem
with python).  A reboot of the system (Mac OS X 10.5.6) doesn't solve
the problem.  I would appreciate any hint.

--
Arnaud Delobelle.


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



Re: Strange 404 error in admin

2009-02-09 Thread Julien Phalip

On Feb 10, 7:52 am, Julien Phalip  wrote:
> On Feb 10, 7:41 am, Alex Gaynor  wrote:
>
> > I don't know what manager old forms admin used, but do you have a custom
> > manager that blocks access to some objects.
>
> Thanks Alex for your reply. You've made a really good point which
> helped me track this down. Here are the model and manager:
>
> class PublishedEntryManager(models.Manager):
>         def get_query_set(self):
>                 return super(PublishedEntryManager, 
> self).get_query_set().filter
> (pub_date__lte=datetime.now)
>
> class Entry(models.Model):
>         ... some fields ...
>         pub_date = models.DateTimeField()
>
>         published = PublishedEntryManager()
>
> In fact, if an entry has a pub_date set in the future, then it is not
> accessible in the admin. Somehow the admin seems to be using the
> PublishedEntryManager as default manager. Is there a way to force the
> admin to use the default manager?
>
> Thanks again,
>
> Julien

Hello again,

I finally fixed it with the following nasty hack:

class Entry(models.Model):
... some fields ...

objects = models.Manager() # Nasty hack
published = PublishedEntryManager()

It seems like the 'change_state' view uses the custom manager instead
of the default one. Explicitly setting 'objects' make it work. If you
can think of a more elegant fix, please let me know ;)

Regards,

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



FormSet with non input-element data possible?

2009-02-09 Thread Info Cascade

Hi --

I'm creating a FormSet and want to include some data in the form output
that is not an html input element.

Some of the data I pass to the FormSet, which gets passed to the form, I
just want to display, I don't want to put it into an HTML input
element.  I want it to be available in the template.  Here is what I
tried, which doesn't work:


class SectionForm(forms.Form):
section_id = forms.IntegerField(label='Section ID:', required=False,
widget=forms.HiddenInput())
section_title = forms.CharField(label='Title', required=True)
section_text = forms.CharField(label='', widget=forms.Textarea,
required=True)
  
def __init__(self, data=None, auto_id='id_%s', prefix=None,
initial=None, empty_permitted=False):
super (SectionForm, self).__init__(data, auto_id, prefix,
initial, empty_permitted)
   
# This is what I want to do, more or less, but it won't work
(TypeError: unscriptable object)
#self.s3_audio_file = initial['s3_audio_file']


In the template, I want to display s3_audio_file, but I don't need or
want it to be editable.  It's for information only.  Just text, or
html-formatted text.

{{ form.s3_audio_file }}

Is there some way to have the form contain arbitrary data that I pass to
it with the "initial" dictionary?
Perhaps, I have to create a faux Widget and Custom field?  That seems
like a long way around for something that should be simple.

Thanks in advance for any help.

Best,
Liam


Also, I was unsure about what to do with empty_permitted -- I got an
error before I added it to the  super() call.






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



Re: Subclass conflict with admin widgets

2009-02-09 Thread Daniel Roseman

On Feb 9, 7:28 pm, phoebebright  wrote:
> I have implemented this solution successfully with a standard model,
> but when I try to use it on one which is subclassed I get an error
> because it is trying to validate the model before it knows about the
> subclass.  I can work around this by defining an Admin class for each
> of the subclasses, but it seems to me this should work?
>
> Model.py
>
> class Directory(models.Model):
>     name = models.CharField(max_length=60)
>     pic1 = models.ImageField(upload_to='pics', blank=True,
> null=True)
>
> class Business(Directory):
>     cat = models.ForeignKey(Subcategory)
>
> Admin.py
>
> AdminImageWidget defined 
>
> class DirectoryAdminForm(forms.ModelForm):
>     pic1 = forms.ImageField(widget=AdminImageWidget())
>
>     class Meta:
>         model = Directory
>
> class DirectoryAdmin(admin.ModelAdmin):
>
>     form = DirectoryAdminForm
>
>     fieldsets = [
>         (None,   {'fields': ['cat','name','is_live']}),    <
> CAT FIELD IS PART OF BUSINESS NOT DIRECTORY SO CAUSES ERROR
>         ('Contact', {'fields':
> ['phone','mobile','fax','email','web','address']}),
>         ('Details', {'fields':
> ['description','pic1','pic2','pic3','pic4']}),
>     ]
>
> admin.site.register(Business,DirectoryAdmin)
>
> Error
>
> ImproperlyConfigured at /admin/town/business/14/
>
> 'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
> is missing from the form.

The error message tells you what is going on. Your form definition has
model=Directory in its Meta class, so it only contains fields from the
Directory model. If you want it to contain the fields from the
subclassed Business model, you'll need to change that Meta
declaration.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange 404 error in admin

2009-02-09 Thread Julien Phalip

On Feb 10, 7:41 am, Alex Gaynor  wrote:
> I don't know what manager old forms admin used, but do you have a custom
> manager that blocks access to some objects.

Thanks Alex for your reply. You've made a really good point which
helped me track this down. Here are the model and manager:

class PublishedEntryManager(models.Manager):
def get_query_set(self):
return super(PublishedEntryManager, self).get_query_set().filter
(pub_date__lte=datetime.now)

class Entry(models.Model):
... some fields ...
pub_date = models.DateTimeField()

published = PublishedEntryManager()

In fact, if an entry has a pub_date set in the future, then it is not
accessible in the admin. Somehow the admin seems to be using the
PublishedEntryManager as default manager. Is there a way to force the
admin to use the default manager?

Thanks again,

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



Re: writing a urlpattern for a form submission

2009-02-09 Thread Daniel Roseman

On Feb 9, 8:16 pm, kosuke  wrote:
> I'm sure this will come across as basic to many django users but it
> has got me stuck so any helpful pointers would be appreciated.  I've
> scoured the docs and come up empty.  Upfront apologies done now,
> here's what I got:
>
> Using django forms, i create a form which results in a submission
> string like this:
>
> http://127.0.0.1:8000/shiftcalendar/?year=2010=1=Get+cal...
>
> So in my urls.py I set up a urlpattern like this:
>
> urlpatterns = patterns('local1042.shiftcalendar.views',
>     (r'^$', 'index'),
>     (r'^(?P\w+)/(?P\w+)$', 'showcal'),)
>
> I thought that that would do it, and I've tried every variation you
> could think of, but I'm missing something.  I know I should use POST
> but for debugging I've been using GET.  The index page works just
> fine.  I just can't get it to call the showcal function.
>
> Any thoughts would be appreciated.
>
> Thanks. Kevin

URL patterns don't match GET variables - ie anything after the ?. You
just need to match on /shiftcalendar/, and everything else will be
passed as keys in the request.GET dictionary.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to detect inactivity session time out?

2009-02-09 Thread ydjango

Any one with a clue on

How do I detect time out in my app and give user a page that they have
been timed out due to inactivity.

 I am usingrequest.session.set_expiry(900) , SESSION_COOKIE_AGE =
900 and django standard authentication using autheticate(), login()
 and logout().


On Feb 8, 12:07 pm, ydjango  wrote:
> I am setting inactivity session time out using -
>      a)      request.session.set_expiry(900) and
>     b)  SESSION_COOKIE_AGE = 900
>
> I believe both work exactly the same way. Please correct me if they
> have any different behavior.
>
> How do I detect this time out in my app and give user a page that they
> have been timed out due to inactivity.
> I am using django standard authentication using autheticate(), login()
> and logout()
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange 404 error in admin

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 3:40 PM, Julien Phalip  wrote:

>
> On Feb 9, 7:20 pm, Julien Phalip  wrote:
> > Hi,
> >
> > This is a strange case. I have a simple blog entry model which can be
> > edited in the admin, from the URL that looks like:
> http://www.example.com.au/admin/blog/entry/52/
> >
> > Now, what is strange is that the link above returns a 404. Same with
> > the entry id=51. Yet, entries with id=51,52 do exist.
> >
> > - All other entries (with id < 51) work fine in the admin.
> > - All entries (including id=51,52) work fine on the front end.
> > - Everything works fine when I test it locally on my computer with a
> > replica of the online database.
> >
> > I've never come across something like that, and I'm not sure where to
> > look to debug this. Would you have some hints to suggest?
> >
> > Thanks a lot for your help,
> >
> > Julien
> >
> > PS: It is using a quite old version of Django, a trunk revision
> > between 0.96 and 1.0.
>
> Hi,
>
> I've narrowed down the issue a bit. First, it's using revision 7901,
> that is before newforms-admin.
> The problem is in the 'change_stage' view:
>
> def change_stage(request, app_label, model_name, object_id):
>...
>try:
>manipulator = model.ChangeManipulator(object_id)
>except model.DoesNotExist:
>raise Http404('%s object with primary key %r does not exist' %
> (model_name, escape(object_id)))
>...
>
> When retrieving the manipulator it raises a 'DoesNotExist' exception:
>
> str: Traceback (most recent call last):
>  File "", line 1, in 
>  File "C:\Djangos\catalyst\django\db\models\manipulators.py", line
> 260, in __init__
>self.original_object = self.manager.get(pk=obj_key)
>  File "C:\Djangos\catalyst\django\db\models\manager.py", line 82, in
> get
>return self.get_query_set().get(*args, **kwargs)
>  File "C:\Djangos\catalyst\django\db\models\query.py", line 294, in
> get
>% self.model._meta.object_name)
> DoesNotExist: Entry matching query does not exist.
>
> But I only get that with those two Entry items (id=51,52). Why don't I
> get it for the other items (id < 51)?
>
> I'm really lost here. There must be some kind of corruption in the
> data meaning it cannot find those particular items, but what could it
> be? Again, those 2 blog entries work fine when displayed in the
> frontend.
>
> Do you think it could be a bug in that particular revision of Django
> I'm using?
>
> Any help would be appreciated.
>
> Julien
> >
>
I don't know what manager old forms admin used, but do you have a custom
manager that blocks access to some objects.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Strange 404 error in admin

2009-02-09 Thread Julien Phalip

On Feb 9, 7:20 pm, Julien Phalip  wrote:
> Hi,
>
> This is a strange case. I have a simple blog entry model which can be
> edited in the admin, from the URL that looks 
> like:http://www.example.com.au/admin/blog/entry/52/
>
> Now, what is strange is that the link above returns a 404. Same with
> the entry id=51. Yet, entries with id=51,52 do exist.
>
> - All other entries (with id < 51) work fine in the admin.
> - All entries (including id=51,52) work fine on the front end.
> - Everything works fine when I test it locally on my computer with a
> replica of the online database.
>
> I've never come across something like that, and I'm not sure where to
> look to debug this. Would you have some hints to suggest?
>
> Thanks a lot for your help,
>
> Julien
>
> PS: It is using a quite old version of Django, a trunk revision
> between 0.96 and 1.0.

Hi,

I've narrowed down the issue a bit. First, it's using revision 7901,
that is before newforms-admin.
The problem is in the 'change_stage' view:

def change_stage(request, app_label, model_name, object_id):
...
try:
manipulator = model.ChangeManipulator(object_id)
except model.DoesNotExist:
raise Http404('%s object with primary key %r does not exist' %
(model_name, escape(object_id)))
...

When retrieving the manipulator it raises a 'DoesNotExist' exception:

str: Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Djangos\catalyst\django\db\models\manipulators.py", line
260, in __init__
self.original_object = self.manager.get(pk=obj_key)
  File "C:\Djangos\catalyst\django\db\models\manager.py", line 82, in
get
return self.get_query_set().get(*args, **kwargs)
  File "C:\Djangos\catalyst\django\db\models\query.py", line 294, in
get
% self.model._meta.object_name)
DoesNotExist: Entry matching query does not exist.

But I only get that with those two Entry items (id=51,52). Why don't I
get it for the other items (id < 51)?

I'm really lost here. There must be some kind of corruption in the
data meaning it cannot find those particular items, but what could it
be? Again, those 2 blog entries work fine when displayed in the
frontend.

Do you think it could be a bug in that particular revision of Django
I'm using?

Any help would be appreciated.

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



Re: user defined model

2009-02-09 Thread Dids


> This is extremely unlikely to work, not to mention very inefficient.
> Can you let us know why you want to do this - what's your use case? We
> might be able to suggest a better way of doing it.
> --
> DR.


Users define a set of data they're interested in. Give a mean to get
the data (script, sql ...). The system goes and get the data at
regular interval (save by date)
The user can then review the data (table, charts , trends etc...)
See it as a basic monitoring system where I currently have no idea
what data the users will be interested in.

I guess I can skip the table cration for each entity but I'm worried
the code for data retrieval might get messy. Not to mention the
templates ...

Thanks for your input.

Dids,

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



writing a urlpattern for a form submission

2009-02-09 Thread kosuke


I'm sure this will come across as basic to many django users but it
has got me stuck so any helpful pointers would be appreciated.  I've
scoured the docs and come up empty.  Upfront apologies done now,
here's what I got:

Using django forms, i create a form which results in a submission
string like this:

http://127.0.0.1:8000/shiftcalendar/?year=2010=1=Get+calendar

So in my urls.py I set up a urlpattern like this:

urlpatterns = patterns('local1042.shiftcalendar.views',
(r'^$', 'index'),
(r'^(?P\w+)/(?P\w+)$', 'showcal'),)

I thought that that would do it, and I've tried every variation you
could think of, but I'm missing something.  I know I should use POST
but for debugging I've been using GET.  The index page works just
fine.  I just can't get it to call the showcal function.

Any thoughts would be appreciated.

Thanks. Kevin


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



Re: Question about media in outside forms

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 12:00 PM, Robert Ramírez Vique wrote:

> Hello,
>
> I have been working on some forms which has some ajax behaivour, and I use
> some css and javascripts. This can be used inside a form with {{ form.media
> }}, which outputs the html tags necessary to import all the javascript and
> css to get all the fields working, and without duplicates if the field
> appears more than one time in the page.
>
> But when I use the {{ form.media }} more than once (imagine a for is
> generated for each element of a list and using includes or template tags) I
> don't know how to get just one tag for each media.
>
> Or when I need this behaivour to happen outside a form (with a template
> tag), don't know if this is possible. I mean, the declaration of the media
> and this is automatically included just when needed.
>
> thanks,
>   Robert Ramírez Vique
>   Computer Science Engineer
>
> >
>
The best way to do this would be to make a templatetag that took multiple
form.media instances, added them together(which can be done with media
instances) and then output the response.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Best practice question: subclassing external app components

2009-02-09 Thread bruno desthuilliers

On 9 fév, 00:35, zinckiwi  wrote:
> Hi folks,
>
> I'm just starting to play with django-registration and I want to
> subclass the RegistrationForm for a couple of cosmetic tweaks
> (capitalising the labels on the fields -- there may be a simpler way
> to do this, but indulge me for the purposes of this question). I
> understand that subclassing RegistrationForm and reassigning the label
> strings is the way to do this -- no problem.
>
> My question is where to *put* that subclass. I can think of a few
> places:
>
> - the project itself
> - an "overrides" app dedicated to holding overrides for external apps
> - a "registration_overrides" app dedicated to holding overrides for
> just that one external app
>
> Perhaps there are other ways.

I usually have a special 'project' app that I use for all this kind of
project-specific stuff.


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



Admin Image Handling - ability to display thumb and delete an image - one solution

2009-02-09 Thread phoebebright

In case this helps anyone, here is one implementation  I have 4
pictures attached to each record but would work the same if only one.

Uses sorl-thumbnails and based on snippet here: 
http://www.djangosnippets.org/snippets/934/
written by baumer1122

In models.py
-
used standard models.ImageField


class Car(models.Model):
short_desc = models.CharField(max_length=40)
...
pic1 = models.ImageField("Picture 1", blank=True,
upload_to='pics')
pic2 = models.ImageField("Picture 2", blank=True,
upload_to='pics')
pic3 = models.ImageField("Picture 3", blank=True,
upload_to='pics')
pic4 = models.ImageField("Picture 4", blank=True,
upload_to='pics')

In admin.py
---
from django.contrib.admin.widgets import AdminFileWidget
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.conf import settings
from PIL import Image
import os

from sorl.thumbnail.main import DjangoThumbnail

try:
from sorl.thumbnail.main import DjangoThumbnail
def thumbnail(image_path):
t = DjangoThumbnail(relative_source=image_path, requested_size=
(200,200))
return u'' % (t.absolute_url,
image_path)
except ImportError:
def thumbnail(image_path):
absolute_url = os.path.join(settings.MEDIA_ROOT, image_path)
return u'' % (absolute_url,
image_path)

class AdminImageWidget(AdminFileWidget):
"""
A FileField Widget that displays an image instead of a file path
if the current file is an image.
"""
def render(self, name, value, attrs=None):
output = []
file_name = str(value)
if file_name:
file_path = '%s%s' % (settings.MEDIA_URL, file_name)
try:# is image
Image.open(os.path.join(settings.MEDIA_ROOT,
file_name))
output.append('%s %s%s%s' % \
(file_path, thumbnail(file_name), file_path,
file_name,_('Delete:'), name, _('Change:')))
except IOError: # not image
output.append('%s %s
%s ' % \
(_('Currently:'), file_path, file_name, _
('Change:')))

output.append(super(AdminFileWidget, self).render(name, value,
attrs))
return mark_safe(u''.join(output))


class CarAdminForm(forms.ModelForm):
pic1 = forms.ImageField(widget=AdminImageWidget())
pic2 = forms.ImageField(widget=AdminImageWidget())
pic3 = forms.ImageField(widget=AdminImageWidget())
pic4 = forms.ImageField(widget=AdminImageWidget())

class Meta:
model = Car



class CarAdmin(admin.ModelAdmin):

form = CarAdminForm

def save_model(self, request, obj, form, change):

#handle delete checkbox for pics
if request.POST.get('delete_pic1','off')=='on':
obj.pic1=''

if request.POST.get('delete_pic2','off')=='on':
obj.pic2=''

if request.POST.get('delete_pic3','off')=='on':
obj.pic3=''

if request.POST.get('delete_pic4','off')=='on':
obj.pic4=''

obj.save()



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



Subclass conflict with admin widgets

2009-02-09 Thread phoebebright

I have implemented this solution successfully with a standard model,
but when I try to use it on one which is subclassed I get an error
because it is trying to validate the model before it knows about the
subclass.  I can work around this by defining an Admin class for each
of the subclasses, but it seems to me this should work?

Model.py

class Directory(models.Model):
name = models.CharField(max_length=60)
pic1 = models.ImageField(upload_to='pics', blank=True,
null=True)

class Business(Directory):
cat = models.ForeignKey(Subcategory)


Admin.py

AdminImageWidget defined 

class DirectoryAdminForm(forms.ModelForm):
pic1 = forms.ImageField(widget=AdminImageWidget())

class Meta:
model = Directory

class DirectoryAdmin(admin.ModelAdmin):

form = DirectoryAdminForm

fieldsets = [
(None,   {'fields': ['cat','name','is_live']}),<
CAT FIELD IS PART OF BUSINESS NOT DIRECTORY SO CAUSES ERROR
('Contact', {'fields':
['phone','mobile','fax','email','web','address']}),
('Details', {'fields':
['description','pic1','pic2','pic3','pic4']}),
]

admin.site.register(Business,DirectoryAdmin)


Error

ImproperlyConfigured at /admin/town/business/14/

'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
is missing from the form.

Request Method: POST
Request URL:http://dunmanway.pighaswings.com/admin/town/business/14/
Exception Type: ImproperlyConfigured
Exception Value:

'DirectoryAdmin.fieldsets[2][1]['fields']' refers to field 'cat' that
is missing from the form.

Exception Location: /usr/lib/python2.4/site-packages/django/contrib/
admin/validation.py in check_formfield, line 255



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



Re: user defined model

2009-02-09 Thread Daniel Roseman

On Feb 9, 6:13 pm, Dids  wrote:
> Hi,
>
> I need to update the model.py file at run-time.
>
> Where can I find the file on disk from the views.py please?
>
> What I'm trying to do is : Open model.py , append a new class , invoke
> syncdb.
>
> Thx
> Dids,

This is extremely unlikely to work, not to mention very inefficient.
Can you let us know why you want to do this - what's your use case? We
might be able to suggest a better way of doing it.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread Daniel Roseman

On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
 wrote:
> Hi Alex
>
> Yes I have the line from django.contrib import admin" in urls.py
>

You're going to need to post the whole urls.py. It's a bit hard to
understand why you're getting that error if you do have that line, and
it's not commented out. Please show us the whole file, preferably by
posting it somewhere like dpaste.com.

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



Re: Keep getting NameError at /admin/

2009-02-09 Thread claudio.br...@googlemail.com

Hi Alex

Yes I have the line from django.contrib import admin" in urls.py

On 9 Feb, 16:20, Alex Gaynor  wrote:
> On Mon, Feb 9, 2009 at 11:11 AM, claudio.br...@googlemail.com <
>
>
>
> claudio.br...@googlemail.com> wrote:
>
> > Hi
>
> > I am new to django and have just started to play. I have a working
> > (small) app but wanted to turn on the admin console for the project. I
> > edited the settings.py to include the admin module and now get the
> > following errors
>
> > NameError at /admin/
>
> > name 'admin' is not defined
>
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/admin/
> > Exception Type: NameError
> > Exception Value:
>
> > name 'admin' is not defined
>
> > although I first saw the error using django 1.0.2, I can re-create it
> > using 0.96. I have come to the conclusion that I am doing something
> > wrong but can anyone tell me what?
>
> > the relevant part of my settings.py looks like;
>
> > INSTALLED_APPS = (
> >'django.contrib.auth',
> >'django.contrib.contenttypes',
> >'django.contrib.sessions',
> >'django.contrib.sites',
> >'django.contrib.admin',
> > )
>
> > and URLS looks like
>
> ># Uncomment the next line to enable the admin:
> > (r'^admin/(.*)', admin.site.root),
> > )
>
> > i have removed evrything else from the project and app and still get
> > the errror, at the top of the urls.py it makes no difference whether I
> > have the line admin.autodiscover() or not as I still get the error
>
> > Regards
>
> > K
>
> Do you have the line "from django.contrib import admin" in your urls.py?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: checkboxInput values

2009-02-09 Thread Bobby Roberts

> What is the proper way to assign a value to a single checkbox?  Am I
> just stuck with boolean and true/false?  That seems like a lot of
> extra work on the back end.


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



Re: signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Robocop

Holy crap it is!  Thanks for the idea, i'm going to do a lil testing
and verify everything works.  Thanks again!

On Feb 9, 10:21 am, Jake Elliott  wrote:
> hi robocop -
>
> is it enough to add the '**kwargs' syntax to your receiver function?
> or is that already present?
>
> like:
>
> def _save(self, **kwargs):
>     ...
>
> and
>
> def delete(**kwargs):
>     ...
>
> -jake
>
> On Mon, Feb 9, 2009 at 12:15 PM, Robocop  wrote:
>
> > Hello,
> > I've recently been porting many projects to 1.0, but have hit a snag
> > with the current one.  I'm looking at an old project that uses nesh's
> > django utils (mainly just the thumbnail image field model), and have
> > been slowly porting the project (and by extension nesh's code) to
> > 1.0.  Now i have read the documentation on signals, as well as the
> > porting to 1.0 guide's signals section, but because i have not really
> > used signals in my projects, i'm a little unsure what exactly is being
> > called for by this error, and thought someone here may be of some
> > help.
>
> > The original code looked like:
>
> >    def contribute_to_class(self, cls, name):
> >        super(ImageWithThumbnailField, self).contribute_to_class(cls,
> > name)
> >        dispatcher.connect(_delete, signals.post_delete, sender=cls)
> >        dispatcher.connect(self._save, signals.pre_save, sender=cls)
>
> > My poor attempt at porting:
>
> >      def contribute_to_class(self, cls, name):
> >        super(ImageWithThumbnailField, self).contribute_to_class(cls,
> > name)
> >        signals.post_delete.connect(_delete, sender=cls)
> >        signals.pre_save.connect(self._save, sender=cls)
>
> > and the resultant error:
>
> > line 45, in contribute_to_class
> >    signals.post_delete.connect(_delete, sender=cls)
> >  File "/usr/lib/python2.4/site-packages/django/dispatch/
> > dispatcher.py", line 84, in connect
> >    assert argspec[2] is not None, \
> > AssertionError: Signal receivers must accept keyword arguments
> > (**kwargs).
>
> > now my understanding of the syntax is that _delete and self._save
> > would be keyword arguments, but apparently i am incorrect.  Any help
> > or suggestions 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Looking to give presentation on Django at work

2009-02-09 Thread jeffself

I already have the demo in place.  I just wanted to spruce it up with
a presentation and wanted to know if something already existed that I
could work from.  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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



checkboxInput values

2009-02-09 Thread Bobby Roberts

If i use the multiple Checkbox Input, It results in list of the items
which were selected.

My question is can you do the same thing for a single checkbox?

As an old ASP guy I'd do this:




I'm trying to do this in django by the following:




#...snip forms.py
el1_Choices = (
('EN', 'ENGLISH'),
)

el1=forms.ChoiceField (required=False, choices=el1_Choices,
widget=forms.CheckboxInput(attrs={'class':'multibox'}) )


The resulting HTML is:




As you can see there is no value.  It is returning the following
error:

Select a valid choice. That choice is not one of the available
choices.

Even though I've got the form field setup to required=False.




What is the proper way to assign a value to a single checkbox?  Am I
just stuck with boolean and true/false?  That seems like a lot of
extra work on the back end.


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



Re: signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Jake Elliott

hi robocop -

is it enough to add the '**kwargs' syntax to your receiver function?
or is that already present?

like:

def _save(self, **kwargs):
...

and

def delete(**kwargs):
...

-jake

On Mon, Feb 9, 2009 at 12:15 PM, Robocop  wrote:
>
> Hello,
> I've recently been porting many projects to 1.0, but have hit a snag
> with the current one.  I'm looking at an old project that uses nesh's
> django utils (mainly just the thumbnail image field model), and have
> been slowly porting the project (and by extension nesh's code) to
> 1.0.  Now i have read the documentation on signals, as well as the
> porting to 1.0 guide's signals section, but because i have not really
> used signals in my projects, i'm a little unsure what exactly is being
> called for by this error, and thought someone here may be of some
> help.
>
> The original code looked like:
>
>def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>dispatcher.connect(_delete, signals.post_delete, sender=cls)
>dispatcher.connect(self._save, signals.pre_save, sender=cls)
>
> My poor attempt at porting:
>
>  def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>signals.post_delete.connect(_delete, sender=cls)
>signals.pre_save.connect(self._save, sender=cls)
>
> and the resultant error:
>
> line 45, in contribute_to_class
>signals.post_delete.connect(_delete, sender=cls)
>  File "/usr/lib/python2.4/site-packages/django/dispatch/
> dispatcher.py", line 84, in connect
>assert argspec[2] is not None, \
> AssertionError: Signal receivers must accept keyword arguments
> (**kwargs).
>
>
> now my understanding of the syntax is that _delete and self._save
> would be keyword arguments, but apparently i am incorrect.  Any help
> or suggestions 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



user defined model

2009-02-09 Thread Dids

Hi,

I need to update the model.py file at run-time.

Where can I find the file on disk from the views.py please?

What I'm trying to do is : Open model.py , append a new class , invoke
syncdb.

Thx
Dids,

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



signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Robocop

Hello,
I've recently been porting many projects to 1.0, but have hit a snag
with the current one.  I'm looking at an old project that uses nesh's
django utils (mainly just the thumbnail image field model), and have
been slowly porting the project (and by extension nesh's code) to
1.0.  Now i have read the documentation on signals, as well as the
porting to 1.0 guide's signals section, but because i have not really
used signals in my projects, i'm a little unsure what exactly is being
called for by this error, and thought someone here may be of some
help.

The original code looked like:

def contribute_to_class(self, cls, name):
super(ImageWithThumbnailField, self).contribute_to_class(cls,
name)
dispatcher.connect(_delete, signals.post_delete, sender=cls)
dispatcher.connect(self._save, signals.pre_save, sender=cls)

My poor attempt at porting:

  def contribute_to_class(self, cls, name):
super(ImageWithThumbnailField, self).contribute_to_class(cls,
name)
signals.post_delete.connect(_delete, sender=cls)
signals.pre_save.connect(self._save, sender=cls)

and the resultant error:

line 45, in contribute_to_class
signals.post_delete.connect(_delete, sender=cls)
  File "/usr/lib/python2.4/site-packages/django/dispatch/
dispatcher.py", line 84, in connect
assert argspec[2] is not None, \
AssertionError: Signal receivers must accept keyword arguments
(**kwargs).


now my understanding of the syntax is that _delete and self._save
would be keyword arguments, but apparently i am incorrect.  Any help
or suggestions 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Extending the User model

2009-02-09 Thread Patricio Palma


Thanks, I owe you a chocolate bar

I fix it

class MyUser(User):
chilean_rut  = CLRutField(_('RUT'),unique=True)
some_field = models.CharField(max_length=50)

voalá
I don't really need a PK, my mistake
Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeEncodeError with gettext

2009-02-09 Thread Karen Tracey
On Mon, Feb 9, 2009 at 12:21 PM, Scott  wrote:

>
> Thanks for the quick reply - does anyone know if Django 1.0 is patched
> into the Google App Engine Django Helper?
>

Per
http://code.google.com/p/google-app-engine-django/source/browse/trunk/CHANGES

any reasonably current level of the app engine helper requires at least
Django 1.0 beta1.  So far as I know, though, it doesn't provide it, rather
you have to include it as part of your app.  Which is a bit of a pain since
Django as shipped contains more than 1,000 files and a GAE app is limited to
no more than 1,000 files.  This page:

http://code.google.com/appengine/articles/django10_zipimport.html

under "Archiving Django 1.0" provides some details on bits of the django
tree you can omit from your django.zip file (e.g. translations you won't
need) so that you can keep within GAE limits and still use Django 1.0.

Karen

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



Re: UnicodeEncodeError with gettext

2009-02-09 Thread Scott

Thanks for the quick reply - does anyone know if Django 1.0 is patched
into the Google App Engine Django Helper?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Looking to give presentation on Django at work

2009-02-09 Thread lazyant

Hi, it can be very powerful if as part of the presentation you add a
little hands-on demo, like in: 
http://www.showmedo.com/videos/video?name=110=110
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A quick question about slug fields

2009-02-09 Thread djandrow

Thanks Karen

On Feb 9, 4:53 pm, Karen Tracey  wrote:
> On Mon, Feb 9, 2009 at 11:50 AM, djandrow  wrote:
>
> > I believe these days a statment like this has been depreciated:
>
> > post_slug = models.SlugField(prepopulate_from=('post_title',))
>
> > I had a look through the docs but couldn't find the answer.
> > How can you now specify which field the slug is created from?
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#prepopulated-...
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Bizarre sqlite3 / apache2 behaviour

2009-02-09 Thread lazyant

Hello,

I installed yesterday Django 1.0.2 (current downloadable version) on a
new Ubuntu 8.10 machine with python 2.5.2. I wrote a toy application
and it works and shows fine with both the built-in development server
and Apache 2 (2.2.9). The database is sqlite3, it came with python
(btw, how do I get the sqlite3 version from python/the Linux command
line?).

Anyways, yesterday everything was working fine, including the admin
application served by Apache. Today I only worked on templates,
restarting apache frequently (I know about setting MaxRequestsPerChild
1 but anyways) but after a while I went to the admin application
(served by apache) and I got an error: "OperationalError: attempt to
write a readonly database", which is strange since it was working
before and I haven't made today any changes to file or directory
permissions or fiddled with the settings file.

I looked up this error and I only see tips regarding permissions
problems, bad path in the setting file or perhaps a sqlite version
issue. I think none of that applies to me (since it was working
yesterday)  but I double-checked just in case.

I tried different things for troubleshooting, including dropping the
data with "manage.py sqlclear" and renaming the db file and re-
creating it with "manage.py reset" and "manage.py syncdb" (I suspected
perhaps the file was corrupted), but nothing I tried worked. I also
checked the server (it wasn't rebooted recently etc).

Here's a twist: if I start the development server and I log in, then
the admin app in apache works fine (!), I can edit & save records etc.
As soon as I log out of the development server, then apache gives me
the readonly error.

I'm ruling out client-side issues (cookies etc) since I tried with
different browsers and computers, deleting session and cookies etc.

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



Question about media in outside forms

2009-02-09 Thread Robert Ramírez Vique
Hello,

I have been working on some forms which has some ajax behaivour, and I use
some css and javascripts. This can be used inside a form with {{ form.media
}}, which outputs the html tags necessary to import all the javascript and
css to get all the fields working, and without duplicates if the field
appears more than one time in the page.

But when I use the {{ form.media }} more than once (imagine a for is
generated for each element of a list and using includes or template tags) I
don't know how to get just one tag for each media.

Or when I need this behaivour to happen outside a form (with a template
tag), don't know if this is possible. I mean, the declaration of the media
and this is automatically included just when needed.

thanks,
  Robert Ramírez Vique
  Computer Science Engineer

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



Re: Exception in Django's Exception Handling

2009-02-09 Thread Devel63

I'll see if I can extract some small subset and post the details.

In the meantime, more info: the problem only occurs when an error is
encountered during a call in which the server will return a
HttpResponse('', mimetype='text/xml; charset=utf-8') object in
response to some AJAX request; things apparently work when the server
will return a render_to_response, which shows a page in the browser.

Before I switched to Django, and just used webapp (a simplified
version of Django in Google App Engine), the first type of problem
would dump the stack trace to the console.  Now, the trace does not go
to the console, and it is here that the exception within the exception
is thrown.

Could this be a setting or path issue?


On Feb 8, 3:00 pm, Karen Tracey  wrote:
> On Sun, Feb 8, 2009 at 2:20 PM, Devel63  wrote:
>
> > Django is raising an exception while trying to process an exception,
> > resulting in no stack traces ... for many different types of errors.
>
> > It has the problem in debug.py, at this line under
> > technical_500_response:
> >    return HttpResponseServerError(t.render(c), mimetype='text/html')
>
> > I have DEBUG=True, and TEMPLATE_DEBUG = DEBUG.  The situation arises
> > for almost any error (undefined var, missing func arg, call to
> > undefined member func, etc.), but in some cases it does actually
> > generate a stack trace!
>
> Ditto what Russ said: I've not seen this.  Your earlier note, which I had in
> my list of things to go back to and try to answer when I had more time if no
> one else responded, mentions you are using Google App Engine...does that
> apply to what you are talking about here?  I've not done a lot with GAE, but
> some,and I haven't seen this behavior there either -- I get regular Django
> debug pages under GAE, though actually I'm only 100% sure of that when
> running in the development environment, I don't know that I've tested it on
> a deployed project.  So specifics of a small test case that demonstrates the
> problem you are seeing would help track this down -- it doesn't seem to be
> behavior people are seeing generally.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A quick question about slug fields

2009-02-09 Thread Karen Tracey
On Mon, Feb 9, 2009 at 11:50 AM, djandrow  wrote:

>
> I believe these days a statment like this has been depreciated:
>
> post_slug = models.SlugField(prepopulate_from=('post_title',))
>
> I had a look through the docs but couldn't find the answer.
> How can you now specify which field the slug is created from?
>

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#prepopulated-fields

Karen

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



A quick question about slug fields

2009-02-09 Thread djandrow

I believe these days a statment like this has been depreciated:

post_slug = models.SlugField(prepopulate_from=('post_title',))

I had a look through the docs but couldn't find the answer.
How can you now specify which field the slug is created from?

thanks,

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



  1   2   >