Re: Custom SQL or database API?

2008-09-02 Thread janedenone

On 2 Sep., 23:14, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-09-02 at 13:12 -0700,janedenonewrote:
> > Hi,
>
> > I am in the process of moving my handmade website to a Django-based
> > version. One of my SQL queries returns all articles by a certain
> > author if this article is not a chapter or section of an article by
> > the same author:
>
> > SELECT pages.id, pages.author_id, motherpages.author_id AS
> > motherauthor
> > FROM pages, pages AS motherpages
> > WHERE motherpages.page_id = pages.mother_id
> > AND pages.author_id = 1234
> > AND pages.author_id <> motherpages.author_id
>
> It should be possible to get the same effect in Django, but exactly what
> you write will depend upon your models. Perhaps you could construct a
> small example of models that show the relations here (in Python). We
> don't all 57 or whatever number of fields you have in each model. It
> should be possible to write an example with only a field or two in each.

Thanks a lot:

class Author(models.Model):
id = models.IntegerField(primary_key=True)

class Page(models.Model):
id = models.IntegerField(primary_key=True)
author = models.ForeignKey(Author)
mother = models.ForeignKey('self', related_name='child_set')

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



Re: How to display Html in my screen

2008-09-02 Thread David Zhou

> I got confused, when i write html scripts in my admin testfield like
> hello and save them in mysql, but when i wanna display them
> in screen, they can not display as bold font as i want, the source
> file writes: 

hello

> > What can i do to make it right? Django autoescapes. See: http://docs.djangoproject.com/en/dev/topics/templates/#how-to-turn-it-off --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---

Re: django web hosting

2008-09-02 Thread David Zhou

60 megs is kind of low for djangohosting.ch's higher plan --  
webfaction, for example, gives 80 mb memory with their lowest plan.

I also really dislike hosts that claim "unlimited" bandwidth, and then  
say in the fine print that "unlimited" really means no more than 200gb  
a month.  In fact, djangohosting.ch's terms of service flat out  
declares that any usage over 200gb is considered "excessive".  Hardly  
unlimited.

It also doesn't appear to offer PostgreSQL as an option -- the front  
page only lists MySQL.


On Sep 2, 2008, at 8:39 PM, Nikos Delibaltadakis wrote:

> If you want just django then http://djangohosting.ch/ is much better  
> than webfaction, i have accounts in both.
> If you want other platforms too, then prefer webfaction.
>
> 2008/9/3 Ed Wong <[EMAIL PROTECTED]>
>
> hi all,
>
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  thanks.
>
>
>
>
>
> -- 
> Nikos Delibaltadakis
>
> >

---
David Zhou
[EMAIL PROTECTED]




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



Re: registering an admin class causes complete meltdown

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 22:16 -0700, Justin Fagnani wrote:
> Of course. I've been doing it this way at the start of conversions and
> this is the first time it's been a problem.

Some internal changes were necessary recently (particularly r8605) to
work around some other problems that have made this kind of problem more
likely to manifest itself. In a way, this is a good thing, since it
ensures you spot the problems earlier. That wasn't the intention of the
fix; just a side-effect.

Regards,
Malcolm



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



Re: registering an admin class causes complete meltdown

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 21:40 -0700, Justin Fagnani wrote:
> I have a very, very simple model that when I register with the admin
> completely kills my app/project. I can't for the life of me figure out
> what's going on. If I don't register the admin class, everything works
> fine, if I do, the nothing that's loaded after the registration can be
> imported, including classes/function from other modules.
> 
> Here's the model and admin:
> 
> class Carrier(models.Model):
> name = models.CharField(max_length=128)
> url = models.URLField(null=True, verify_exists=False)
> 
> def __unicode__(self):
> return self.name
> 
> class CarrierAdmin(admin.ModelAdmin):
> pass
> admin.site.register(Carrier, CarrierAdmin)

Don't put admin registration in the same file as the model definitions.
Model files are imported more than once, which leads to registration
problems. It's also pretty easy to get circular dependencies problems
because of some validation code in the admin interface.

In short, follow the recommended practice and put the Admin class and
reistration into admin.py, rather than models.py

Regards,
Malcolm



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



registering an admin class causes complete meltdown

2008-09-02 Thread Justin Fagnani

I have a very, very simple model that when I register with the admin
completely kills my app/project. I can't for the life of me figure out
what's going on. If I don't register the admin class, everything works
fine, if I do, the nothing that's loaded after the registration can be
imported, including classes/function from other modules.

Here's the model and admin:

class Carrier(models.Model):
name = models.CharField(max_length=128)
url = models.URLField(null=True, verify_exists=False)

def __unicode__(self):
return self.name

class CarrierAdmin(admin.ModelAdmin):
pass
admin.site.register(Carrier, CarrierAdmin)

This model is used in another app. Trying to import models that appear
after register() causes an ImportError. So I moved the register() call
to the end of the file, then models imported after that raised an
ImportError.

I'm a bit lost here, is admin.site.register() modifying __import__()? Any ideas?

Thanks,
  Justin

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



Re: My site die every two hours

2008-09-02 Thread Jason Cui

Sorry, it's my fault, the DEBUG is setted to true in settings file.

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



Re: Where is the source code for Practical Django Projects?

2008-09-02 Thread James Bennett

On Tue, Sep 2, 2008 at 8:13 PM, Joeyx2 <[EMAIL PROTECTED]> wrote:
> Still waiting on that source code?

Guys, I promise you all that there will be a loud and triumphant
announcement on my blog when the package goes up. With Django 1.0
landing and the final changes from that still being worked on, it's
still going to take a bit of time.


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

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



Re: Testing framework observations

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 18:45 -0700, ballparkfh wrote:
> My fixtures won't load unless I name them "initial_data".  What is the
> reason for this?

Based on the complete lack of example code you've provided, it's
difficult to tell. Perhaps post a short example of your TestCase-derived
class so we cna see what the "fixtures" line looks like.

Regards,
Malcolm



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



inlineformset_factory ValidationError

2008-09-02 Thread Aaron

Hi, has anyone encounter a similar error?


ValidationError at /post/add/
[u'ManagementForm data is missing or has been tampered with']


I am able to display the inline form, but the error occurs when I try
to pass the request.POST data into the PostImageFormSet

Below is my view:
---
def add_post(request):

section_id = int(request.GET.get('s', 0))
category_id = int(request.GET.get('c', 0))

PostImageFormSet = \
inlineformset_factory(Post, PostImage, max_num=1)

if request.method == 'POST':
form = PostForm(data=request.POST)
formset = PostImageFormSet(data=request.POST)
if form.is_valid() and formset.is_valid():
new_post = form.save(commit=False)
new_post.poster = request.user
new_post.save()
formset.instance = new_post
formset.save()
return HttpResponseRedirect(new_post.get_absolute_url())
else:
form = PostForm()
formset = PostImageFormSet()

return render_to_response('classified/post_form.html',
  { 'form': form,
'formset': formset,
'add': True,
'section_id': section_id,
'category_id': category_id,
'categories':
Category.objects.all() },
 
context_instance=RequestContext(request))

---

Any helpful info regarding this error will be greatly appreciated.

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



Re: Where is the source code for Practical Django Projects?

2008-09-02 Thread Ray Smith


I'd be pretty sure 99.999% of Django people are happy for James to keep
working 1.0 final released before getting the fully updated source code for
the book completed ;)

Regards,

Ray Smith
http://RaymondSmith.com


On Tue, 2 Sep 2008 18:13:34 -0700 (PDT), Joeyx2 <[EMAIL PROTECTED]>
wrote:
> 
> Still waiting on that source code?
> 
> On Aug 15, 9:42 am, Feisal <[EMAIL PROTECTED]> wrote:
>> Wondering the same.
>> Excellent book!
>>
>> On 4 Aug., 12:32, Kent Primrose <[EMAIL PROTECTED]> wrote:
>>
>> > Thanks for the great book James. I'm really enjoying it.
>>
>> > Any word on thesourcecode? I understand the pressures of a day job,
>> > so not nagging. Just wondering where it will be posted when it's ready
>> > so I can keep checking there. Will it be on the APress site?
>>
>> > Thanks again,
>> > Kent



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



ANNOUNCE: Django 1.0 release candidate now available

2008-09-02 Thread James Bennett

We've just put up the package for the first Django 1.0 release
candidate; this package contains all of the progress made on Django
through the alpha and beta releases, and is fairly close to the final
Django 1.0 release. It's still not recommended for production use, but
we do encourage everyone to check it out and help us identify any
remaining bugs; the next step in this process is the final Django 1.0
release, and we need your help to make it as smooth as possible.

Download: http://www.djangoproject.com/download/
Release notes: http://docs.djangoproject.com/en/dev/releases/1.0/
Package checksums:
http://media.djangoproject.com/pgp/Django-1.0-rc_1.checksum.txt


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

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



Re: django web hosting

2008-09-02 Thread Nikos Delibaltadakis
If you want just django then http://djangohosting.ch/ is much better than
webfaction, i have accounts in both.
If you want other platforms too, then prefer webfaction.

2008/9/3 Ed Wong <[EMAIL PROTECTED]>

>
> hi all,
>
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  thanks.
>
> >
>


-- 
Nikos Delibaltadakis

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



Re: django web hosting

2008-09-02 Thread David Zhou

I've had pretty good experiences with WebFction.

David

Sent from my iPhone

On Sep 2, 2008, at 7:30 PM, Ed Wong <[EMAIL PROTECTED]> wrote:

>
> hi all,
>
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  thanks.
>
> >

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



Re: OT: Google Chrome

2008-09-02 Thread Jon Brisbin
I tried it on my Windows VM (still waiting on a Mac version) and it  
seemed quite fast. Since it's WebKit, I'm hoping it'll be as easy to  
develop for as Safari. I like that Gears is integrated, though I  
haven't yet used Gears in an app (it's on my list! :). I'm seriously  
considering using gears in my admin app for desktop browsers (the  
nature of the admin interface means you won't be doing much admin on  
the iPhone...mostly read-only).

I think NPR was right about it, when they reported on it this  
afternoon: most people won't bother using anything other than IE  
because that's what's installed on their PC and it's what they know  
(we've standardized on Firefox at work and most people still use IE,  
though I've convinced some to switch).

I can't begin to describe how much I HATE hacking what I write to work  
on IE. I think that's why I've gravitated to the iPhone. Closed  
platform or not, it's great to have some stability and predictability  
as a developer. I've never really had that before and it's kind of nice.

Thanks!

Jon Brisibn
http://jbrisbin.com

On Sep 2, 2008, at 6:41 PM, James Matthews wrote:

> HI List,
>
> Today Google released chrome. I have been playing around with it a  
> little today. Besides for seeing some funny things (try https://www.gmail.com 
>  Thanks reddit) It seems to be a very nice browser. I would like to  
> see where it's path is going to go. What are your thoughts?
>
> James
>
> -- 
> http://www.goldwatches.com/
>
> >


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



Re: django web hosting

2008-09-02 Thread Ray Smith


Hi,

Have you looked at:

http://djangofriendly.com/hosts/
 
Regards,

Ray Smith
http://RaymondSmith.com


On Tue, 2 Sep 2008 16:30:56 -0700 (PDT), Ed Wong <[EMAIL PROTECTED]> wrote:
> 
> hi all,
> 
> i am looking for a good web host for my django website.  does anyone
> suggest a good host?  thanks.
> 
> 


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



django web hosting

2008-09-02 Thread Ed Wong

hi all,

i am looking for a good web host for my django website.  does anyone
suggest a good host?  thanks.

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



YUI uploader + CSRF + Firefox + Windows = 403

2008-09-02 Thread tom

Hi there,

I wonder if there is someone out there who can help me to work around
the flash bug, where the wrong session cookies are sent to the server.
I would like to activate CSRF together with AJAX
(document.getElementById('csrfmiddlewaretoken')).
It is working in each and every browser, but not in firefox under
windows.

Does someone know how I can 'append' the document.cookie to the upload
request, as stated on the YUI uploader page (http://
developer.yahoo.com/yui/uploader/)?

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



Re: Url template tag errors post-8760, invalid literal for int

2008-09-02 Thread bhunter

Is it possible this is still broken?  I just updated to r8883 and now
some of my {% url %} tags are breaking.  I'm seeing a
TemplateSyntaxError because the argument is not being converted to a
string before being resolved.

In other words, this example is breaking:

urls.py:
  r('^view/num=(\d+)'), 'some_view'),

models.py:
  class myModel(models.Model):
num = models.PositiveIntegerField()

def __str__():
  return "%d" % num

some_page.html:
  {% url some_view model_number %}
where model_number is an instance of myModel

The problem here is that the urlresolver is looking for this:
'view/num='
when it used to look for this:
'view/num=7'

Apologies if there are errors in my example, I'm typing this on-the-
fly just to illustrate the problem.  I believe this mistake was
introduced since r8580, since that's where I was before I did an
update.

Thanks,
Brian



On Sep 1, 7:03 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-09-01 at 15:59 -0700, Malcolm Tredinnick wrote:
>
> > On Mon, 2008-09-01 at 15:55 -0700, Dave Lowe wrote:
> > > I wish I could find that. I've already been looking for anything like
> > > that and keep coming up empty. None of theURLvariables I'm using
> > > include '}'.
>
> > Not the variables. The regular-expression patterns. In one of your
> > urls.py files.
>
> Don't worry. I worked it out. It's fixed in r8825.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: geodjango join problem

2008-09-02 Thread robstar

Oops, forgot to paste that in .. I've got that in there.



On Sep 2, 6:29 pm, Justin Bronn <[EMAIL PROTECTED]> wrote:
> > class Location(models.Model):
> >   geo_loc         = models.PointField()
>
> > The thing that strikes me as strange is that the geomanager doesn't
> > show up at all in the traceback...  not sure why I can't do a join on
> > geo_loc ?!
>
> > Thanks for your help.
>
> You need to put `objects = models.GeoManager()` in your `Location`
> model.  I don't see it in the code you provided.
>
> Regards,
> -Justin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: geodjango join problem

2008-09-02 Thread Justin Bronn

> class Location(models.Model):
>   geo_loc         = models.PointField()
>
> The thing that strikes me as strange is that the geomanager doesn't
> show up at all in the traceback...  not sure why I can't do a join on
> geo_loc ?!
>
> Thanks for your help.

You need to put `objects = models.GeoManager()` in your `Location`
model.  I don't see it in the code you provided.

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



ANNOUNCE: Security updates for Django trunk, 0.96, 0.95 and 0.91

2008-09-02 Thread James Bennett

In accordance with our security policy[1], today the Django project is
issuing a set of releases to fix a security vulnerability reported to
us. This message contains a description of the vulnerability, a
description of the changes made to fix it, and pointers to the patches
for each supported version of Django.


Description of vulnerability


The Django administration application, as a convenience for users
whose sessions expire, will attempt to preserve HTTP POST data from an
incoming submission while re-authenticating the user, and will -- on
successful authentication -- allow the submission to continue without
requiring data to be re-entered.

Django developer Simon Willison has presented the Django development
team with a proof-of-concept cross-site request forgery (CSRF) which
exploits this behavior to perform unrequested deletion/modification of
data. This exploit has been tested and verified by the Django team,
and succeeds regardless of whether Django's bundled CSRF-protection
module is active.


Affected versions
=

* Django development trunk
* Django 0.96
* Django 0.95
* Django 0.91


Resolution
==

As it represents a persistent vector for CSRF attacks, this behavior
is being removed from Django; henceforth, attempted posts from users
whose sessions have expired will be discarded and the data will need
to be re-entered.

This is, then, backwards-incompatible with existing behavior and may
be considered a feature removal; however, the Django team feel that
the security risks of this feature outweigh its minor utility.

The fix for this issue was applied to the Django repository in
changeset 8877, which contains the relevant changes for each affected
version::

http://code.djangoproject.com/changeset/8877

Based on these changes, the Django team is issuing three new releases:

* Django 0.96.3: http://www.djangoproject.com/download/0.91.3/tarball/
* Django 0.95.4: http://www.djangoproject.com/download/0.95.4/tarball/
* Django 0.91.3: http://www.djangoproject.com/download/0.96.3/tarball/

The relevant patch has been applied to Django trunk as well, and so
will be included in the forthcoming Django 1.0 release candidate (to
be issued later today) and the final Django 1.0 release.

All users of affected Django versions are encouraged to upgrade
immediately.

A file containing the MD5 and SHA1 checksums of the new release
packages has been placed on the ``djangoproject.com`` server::


http://media.djangoproject.com/pgp/django-security-releases-20080901.checksums.txt

This file is PGP-signed with the Django release manager's public
key. This key has the fingerprint ``0x8C8B2AE1`` and can be obtained
from, e.g., the MIT PGP keyserver::

http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8C8B2AE1


Release manager's note
==

If you are currently maintaining and distributing a packaged version
of Django (e.g., for a Linux or other Unix distribution), or if you
are a hosting company which officially supports Django as an option
for customers, and you did **not** receive an advance notification of
this issue, please contact Django's release manager (James Bennett,
james at b-list dot org) as soon as possible so that you can be added
to the list of known distributors who receive such notifications.


[1]
http://www.djangoproject.com/documentation/contributing/#reporting-security-issues


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

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



geodjango join problem

2008-09-02 Thread robstar

Hi guys,

I just got geodjango installed and am trying to do a basic radius
query as shown on the wiki.

ver: Django-1.0-beta_2

class Location(models.Model):
  geo_loc = models.PointField()


This is the example:

from django.contrib.gis.geos import *
from suitengine.models import Location
from django.contrib.gis.measure import D

x = Point(-94.36229240, 33.75653901)
qs = Location.objects.filter(geo_loc__distance_lte=(x, D(km=7)))


Here is the error:

Traceback (most recent call last):
  File "", line 1, in 
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/
manager.py", line 90, in filter
return self.get_query_set().filter(*args, **kwargs)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/query.py",
line 481, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/query.py",
line 499, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/
query.py", line 1189, in add_q
can_reuse=used_aliases)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/
query.py", line 1061, in add_filter
parts, opts, alias, True, allow_many, can_reuse=can_reuse)
  File "/root/django-svn/Django-1.0-beta_2/django/db/models/sql/
query.py", line 1377, in setup_joins
raise FieldError("Join on field %r not permitted." % name)
FieldError: Join on field 'geo_loc' not permitted.


The thing that strikes me as strange is that the geomanager doesn't
show up at all in the traceback...  not sure why I can't do a join on
geo_loc ?!

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



Re: Problem with ImageField and inline admin form

2008-09-02 Thread Aaron

Hi,

I have similar models and wanted to do the same thing.  Here's how I
got my inline to work (using your provided models as an example).

class Entry(models.Model):
pub_date = models.DateTimeField('date published')
created = models.DateTimeField(auto_now_add=True, editable=False)
edited = models.DateTimeField(auto_now=True, editable=False)
title = models.CharField(max_length=200, blank=True)
title_fi = models.CharField(max_length=200, blank=True)
is_memorial = models.BooleanField('Use special layout?',
default=False)

class Image(models.Model):
entry = models.ForeignKey(Entry, related_name='images')
file = models.ImageField(upload_to="%Y")
caption = models.TextField()
caption_fi = models.TextField()

class ImageInline(admin.TabularInline):
model = Image
extra = 1

class EntryAdmin(admin.ModelAdmin):
date_hierachy = 'pub_date'
list_display = ('pub_date', 'title')
list_filter = ('pub_date',)
ordering = ('-pub_date',)
search_fields = ('pub_date', 'title')
inlines = [
ImageInline,
]




The point is that I didn't need to specify the forms explicitly for
the inline.

Hope this helps.

For reference, check out: http://www.djangoproject.com/documentation/admin/

On Aug 29, 10:44 pm, "Ramin Miraftabi" <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I'm stumped and can't figure out a solution for the following:
>
> With the models:
>
> class Entry(models.Model):
> pub_date = models.DateTimeField('date published')
> created = models.DateTimeField(auto_now_add=True, editable=False)
> edited = models.DateTimeField(auto_now=True, editable=False)
> title = models.CharField(max_length=200, blank=True)
> title_fi = models.CharField(max_length=200, blank=True)
> is_memorial = models.BooleanField('Use special layout?', default=False)
>
> class Image(models.Model):
> entry = models.ForeignKey(Entry, related_name='images')
> file = models.ImageField(upload_to="%Y")
> caption = models.TextField()
> caption_fi = models.TextField()
>
> And forms:
>
> class ImageForm(forms.ModelForm):
> file = forms.ImageField()
> caption = forms.CharField(label='Default caption',
> widget=forms.Textarea)
> caption_fi = forms.CharField(label='Caption in Finnish', required=False,
> widget=forms.Textarea)
>
> class ImageInline(admin.TabularInline):
> model = Image
> extra = 1
> form = ImageForm
>
> class EntryForm(forms.ModelForm):
> pub_date = forms.DateField(label='Publication date',
> initial=datetime.date.today() + datetime.timedelta(1))
> title = forms.CharField(max_length=200, required=False)
> title_fi = forms.CharField(label='Finnish title', max_length=200,
> required=False)
> is_memorial = forms.BooleanField(label='Use special layout?',
> initial=False, required=False)
> tags = forms.CharField(max_length=200,required=False)
>
> class EntryAdmin(admin.ModelAdmin):
> date_hierachy = 'pub_date'
> list_display = ('pub_date', 'title')
> list_filter = ('pub_date',)
> ordering = ('-pub_date',)
> search_fields = ('pub_date', 'title')
> inlines = [
> ImageInline,
> ]
> form = EntryForm
>
> I can easily start creating a new Entry in admin, but trying to open a
> previously created entry results in the following error:
>
> Template error
>
> In template
> /usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/edit_inline/tabular.html,
> error at line *24*
> Caught an exception while rendering: coercing to Unicode: need string or
> buffer, ImageFieldFile found 14 {% endfor %} 15 {% if
> inline_admin_formset.formset.can_delete %}{% trans "Delete?" %}{%
> endif %} 16  17
> 18 {% for inline_admin_form in inline_admin_formset %} 19
> 20  21
> 22  23 {% if inline_admin_form.original or
> inline_admin_form.show_url %} 24 {% if inline_admin_form.original %} {{
> inline_admin_form.original }}{% endif %}
> In Django Alpha 1 this wasn't a problem (in fact I didn't even need to
> define a form for the Image model since in the model I could define old
> stuff).
> With Django 8730 this error appears.
>
> Any ideas?
>
> ramin
> --
> Ramin Miraftabihttp://fierymill.net/ramin/
> blog @http://randomfire.fierymill.net/
>
> Kolme flättiä ja kultsu:http://fierymill.net/loj/
> Three flatcoats and a golden:http://fierymill.net/loj/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: python list issue

2008-09-02 Thread tchendrix
yeah this is a standard non-django form passing a list

bruno desthuilliers wrote:
> On 2 sep, 22:47, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>   
>> interesting situation.  I've got a form
>> 
>
> 'form' as a django.forms.Form instance or as a plain html form ?
>
>   
>> where i can check off items to
>> manipulate in the database, each checkbox containing the recordID to
>> manipulate
>>
>> if i check one box, (recordID # 66) then the length of that value is 2
>>
>> If i check two boxes (record id # 66,67) then the length of the list
>> is 2
>> 
>
>   
>> What command should I be using to give me the number of elements in
>> the list.  I'm currently using len(listnamehere)
>> 
>
> If it's a plain html form and you get your values thru request.POST
> (or GET), remember that  the http protocol is text-based, and that
> len('66') == 2.
>
> django's HttpRequest object's GET and POST are QueryDict instances.
> You may want to use POST.getlist(yourcheckboxnamehere) instead of
> POST[yourcheckboxnamehere], and if you expect integers, do the
> conversion by yourself (hint : map(int, yourlist))
>
> HTH
> >
>   

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



Re: Custom SQL or database API?

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 13:12 -0700, janedenone wrote:
> Hi,
> 
> I am in the process of moving my handmade website to a Django-based
> version. One of my SQL queries returns all articles by a certain
> author if this article is not a chapter or section of an article by
> the same author:
> 
> SELECT pages.id, pages.author_id, motherpages.author_id AS
> motherauthor
> FROM pages, pages AS motherpages
> WHERE motherpages.page_id = pages.mother_id
> AND pages.author_id = 1234
> AND pages.author_id <> motherpages.author_id

It should be possible to get the same effect in Django, but exactly what
you write will depend upon your models. Perhaps you could construct a
small example of models that show the relations here (in Python). We
don't all 57 or whatever number of fields you have in each model. It
should be possible to write an example with only a field or two in each.

Regards,
Malcolm



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



Re: day is out of range for month

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 08:38 -0700, Xiong Chiamiov wrote:
> On a site of ours, we got a 500 on Aug 31 with the error:
> 
> ImproperlyConfigured: Error while importing URLconf 'ee_website.urls':
> day is out of range for month
> 
> from this line:
> 
> announcements = {'queryset':
> Announcement.objects.filter(active=True,expire_date__gt=datetime.today()).order_by('-
> publish_date')}
> 
> Commenting it out, and the lines that depended on it, removed the
> problem.
> Reverting those changes on the 2nd produced a working site.
> 
> I'm not in charge of the servers, but I believe that this one is
> running an svn build that's no more than a few weeks old.

Without a repeatable example, it's impossible to debug stuff like this.
Please come up with a small self-contained case that shows the failure
(you might have to constuct a datetime object with a particular value,
rather than datetime.today(), but since you know the date it failed on,
that shouldn't be too difficult).

Regards,
Malcolm



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



Re: python list issue

2008-09-02 Thread bruno desthuilliers

On 2 sep, 22:47, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> interesting situation.  I've got a form

'form' as a django.forms.Form instance or as a plain html form ?

> where i can check off items to
> manipulate in the database, each checkbox containing the recordID to
> manipulate
>
> if i check one box, (recordID # 66) then the length of that value is 2
>
> If i check two boxes (record id # 66,67) then the length of the list
> is 2

> What command should I be using to give me the number of elements in
> the list.  I'm currently using len(listnamehere)

If it's a plain html form and you get your values thru request.POST
(or GET), remember that  the http protocol is text-based, and that
len('66') == 2.

django's HttpRequest object's GET and POST are QueryDict instances.
You may want to use POST.getlist(yourcheckboxnamehere) instead of
POST[yourcheckboxnamehere], and if you expect integers, do the
conversion by yourself (hint : map(int, yourlist))

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



python list issue

2008-09-02 Thread Bobby Roberts

interesting situation.  I've got a form where i can check off items to
manipulate in the database, each checkbox containing the recordID to
manipulate


if i check one box, (recordID # 66) then the length of that value is 2

If i check two boxes (record id # 66,67) then the length of the list
is 2

What command should I be using to give me the number of elements in
the list.  I'm currently using len(listnamehere)



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



Re: Can't assign None to instance of model (SVN 8463)

2008-09-02 Thread Donn

> This error message makes it appear dimobj is a single-element sequence
> containing None 
You're a genius! I totally missed that. I had a hanging comma and hell 
followed :)

Thx,
\d

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



Re: Can't assign None to instance of model (SVN 8463)

2008-09-02 Thread Karen Tracey
On Tue, Sep 2, 2008 at 4:31 PM, Donn <[EMAIL PROTECTED]> wrote:

>
> Hi,
> My model (Item) has this line:
> dimensions = models.ForeignKey(Dimension, null=True, blank=True )
>
> Later, I want to make an Item sans dimensions like so:
> itemobj = Item(  blah
>dimensions = dimobj,
>)
> But - dimobj is None (as it should be).
>
> I get this error:
> Cannot assign "(None,)": "Item.dimensions" must be a "Dimension" instance.
>

This error message makes it appear dimobj is a single-element sequence
containing None as its single element.  That's not quite the same as None
itself.  Are you sure about what dimobj is?

Karen


>
> I have looked in the docs and it seems this *should* be okay:
> If a ForeignKey field has null=True set (i.e., it allows NULL values), you
> can
> assign None to it *
> *
> http://www.djangoproject.com/documentation/db-api/#one-to-many-relationships
>
> I also checked the 0.96 docs and it's there too. I am on some SVN 8463 now.
>
> What am I missing?
> \d
>
> >
>

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



Can't assign None to instance of model (SVN 8463)

2008-09-02 Thread Donn

Hi,
My model (Item) has this line:
dimensions = models.ForeignKey(Dimension, null=True, blank=True )

Later, I want to make an Item sans dimensions like so:
itemobj = Item(  blah
dimensions = dimobj,
)
But - dimobj is None (as it should be).

I get this error:
Cannot assign "(None,)": "Item.dimensions" must be a "Dimension" instance.

I have looked in the docs and it seems this *should* be okay:
If a ForeignKey field has null=True set (i.e., it allows NULL values), you can 
assign None to it *
* http://www.djangoproject.com/documentation/db-api/#one-to-many-relationships

I also checked the 0.96 docs and it's there too. I am on some SVN 8463 now.

What am I missing?
\d

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



Re: problem with passing dict object to django template

2008-09-02 Thread Matt Berg

Bruno and David,

Thanks. I greatly appreciate the help.

You're right. I should include this in the model and have it handled
by a class. Right now I'm just focused on figuring out the mechanics
of django.

Again, thank you very much for taking the time to explain this.

Matt

On Sep 2, 3:06 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 2 sep, 20:22, Matt Berg <[EMAIL PROTECTED]> wrote:
>
> > Sorry.
>
> > Yes, in the template I do a loop...
>
> > for crop in crops
>
> Where do "crops" come from ? In your above code, you only returned the
> ci dict, no t crops.
>
> > In the view, I make an array ci (cropinfo).
>
> It's actually a dict, not an array.
>
> >  Each ci I append a new
> > dict object (cd) which is associated with the crop id.
>
> > In the template, I just want to loop through the crops
>
> How do you make these crops available to your template ?
>
> > and then
> > display items in the embedded dict that are tied to the crop.id.
>
> It would be simpler to just attach each 'cd' dict to your crop objects
> in the view, then return the list of crops, ie:
>
> def crop_info(season,crops):
>     hectares = 0
>     for c in crops:
>         hectares += c.hectares
>         cd = {}
>         cd['dap_kg_dollar'] = (season.DAP_local_fiftykg_price /
> season.forex_input) / 50
>         cd['urea_kg_dollar'] = (season.urea_local_fiftykg_price /
> season.forex_input) / 50
>         cd['seed_local_dollar'] = c.local_seed_price /
> season.forex_input
>         cd['seed_improved_dollar'] = c.improved_seed_price /
> season.forex_input
>         cd['total'] = (c.seed * cd['seed_improved_dollar']) +
> (cd['urea_kg_dollar'] * c.urea)
>         c.crop_info = cd
>     return crops
>
> Then in your template:
>
> {% for crop in crops %}
> {{crop.id}} : {{ crop.crop_info.total }}
> {% endfor %}
>
> HTH
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom SQL or database API?

2008-09-02 Thread janedenone

Hi,

I am in the process of moving my handmade website to a Django-based
version. One of my SQL queries returns all articles by a certain
author if this article is not a chapter or section of an article by
the same author:

SELECT pages.id, pages.author_id, motherpages.author_id AS
motherauthor
FROM pages, pages AS motherpages
WHERE motherpages.page_id = pages.mother_id
AND pages.author_id = 1234
AND pages.author_id <> motherpages.author_id

Is it possible to do this with the Django database API, or do I need
to retreat to custom SQL?

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



Re: Initial values in form fields

2008-09-02 Thread bruno desthuilliers

On 2 sep, 19:10, cArkraus <[EMAIL PROTECTED]> wrote:
> Hey everyone,
>
> am pretty new to Django and Python in general.
> I seem not be able to let the 'initial' value of a form-field be
> calculated by its parent form.
>
> I'd like to do sth like this:
>
> class AbstractForm(forms.Form):
> some_attr = "foo"
>
> def some_method(self):
> if self.some_attr == "foo": return "foo"
> return "Something else..."
>
> some_field = forms.CharField(initial=self.some_method())
>
> ..but obviously I cant access 'self' when declaring some_field..

Indeed. the AbstractForm class doesn't exists yet, so let's not even
talk about an instance...

> and
> obviously I have yet to learn a lot about Python oop :)

May I recommand comp.lang.py ? FWIW, how functions become methods is
something I explained quite a few times there !-)

> Fyi. I do not want to initiate form defaults like
> f = MyForm(initial=...) in my views since I'd have to repeat that in
> each view.
>
> I'd rather do things like this lateron:
> class ConcreteForm(AbstractForm):
> some_attr = "bar"
>
> Somebody willing to enlighten me?

Honestly, I think Daniel's solution is the way to go... At least, it's
the simplest thing  to do, and it should JustWork(tm).

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



Re: Field type for 13 digit positive integer?

2008-09-02 Thread coan


For now I was planning to store ISBN13 and 13 digit ean codes.

In mysql a bigint field would hold these, but I see no corresponing
fieldtypes in django for bigints -
the positiveintegerfield sets itself up as an int(10) signed field
type in mysql. -
I guess I could store them as charfields, but I think lookups go
faster in a bigintfield.

On Sep 2, 9:50 pm, tchendrix <[EMAIL PROTECTED]> wrote:
> the reason i'm asking is that digits 14 and 15 will be alphanumeric so
> add another field or two for that data (char?) and use bigint to hold
> the numerical data
>
> coan wrote:
> > On Sep 2, 9:36 pm, tchendrix <[EMAIL PROTECTED]> wrote:
>
> >> that looks like it's for an EAN code... how are you planning on EAN14
> >> and EAN 15?
>
> > I will take them on one digit at a time :-)
> > First I have to solve my 13 digit 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Syntax highlight for django template

2008-09-02 Thread coldhitman47

I love gedit and currently using gedit 2.22.3 that comes with really
good python syntax highlight and python console.

I'm wondering if there's django syntax highlight plugin that I can
install.

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



Re: Field type for 13 digit positive integer?

2008-09-02 Thread tchendrix
the reason i'm asking is that digits 14 and 15 will be alphanumeric so 
add another field or two for that data (char?) and use bigint to hold 
the numerical data






coan wrote:
> On Sep 2, 9:36 pm, tchendrix <[EMAIL PROTECTED]> wrote:
>   
>> that looks like it's for an EAN code... how are you planning on EAN14
>> and EAN 15?
>> 
>
> I will take them on one digit at a time :-)
> First I have to solve my 13 digit 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field type for 13 digit positive integer?

2008-09-02 Thread coan

On Sep 2, 9:36 pm, tchendrix <[EMAIL PROTECTED]> wrote:
> that looks like it's for an EAN code... how are you planning on EAN14
> and EAN 15?

I will take them on one digit at a time :-)
First I have to solve my 13 digit 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field type for 13 digit positive integer?

2008-09-02 Thread tchendrix

that looks like it's for an EAN code... how are you planning on EAN14 
and EAN 15?





coan wrote:
> If I want to store a positive integer like 9781590599969 and use mysql
> - what field type can I choose in my model -  if any?
> >
>   

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



Field type for 13 digit positive integer?

2008-09-02 Thread coan

If I want to store a positive integer like 9781590599969 and use mysql
- what field type can I choose in my model -  if any?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: granularpermissions app no longer creates dbtables

2008-09-02 Thread [EMAIL PROTECTED]

in granularpermission/__init__.py there is an import:
line4: from models import Permission

if I comment that import the dbtable is created, so I assume this is a
django problem.




On Sep 2, 8:30 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I've been using granular permissions (http://code.google.com/p/django-
> granular-permissions/) in one of my projects. Just updated django svn
> and it stoped creating the necessary dbtable.
>
> Is anyone using granular permissions that can help me.
>
> Thanks
>
> Luis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



granularpermissions app no longer creates dbtables

2008-09-02 Thread [EMAIL PROTECTED]

Hi,

I've been using granular permissions (http://code.google.com/p/django-
granular-permissions/) in one of my projects. Just updated django svn
and it stoped creating the necessary dbtable.

Is anyone using granular permissions that can help me.

Thanks

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



Re: How is are Fields implemented?

2008-09-02 Thread Abdallah El Guindy
Thanks a lot for the help throughout... I finally managed to solve the
problem :D

Yes you are right, this is getting off-topic and I apologize for that... My
questions end here!

Thanks again

On Tue, Sep 2, 2008 at 9:17 PM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
> On 2 sep, 13:50, "Abdallah El Guindy" <[EMAIL PROTECTED]>
> wrote:
> > Hey Bruno,
> >
> > Thanks a lot! I read now 2 pages on metaclasses and I'm beginning to
> really
> > feel I'm figuring it out...
>
> If you only need to read 2 pages of doc to become proficient with
> metaclasses, then your way smarter than I am.
>
> > I'll read a bit more and once I start
> > implementation and if I have any problems I'll ask back...
>
> This discussion starts to be a bit OT here IMHO. This is more about
> Python metaprogramming than about Django itself. comp.lang.py would be
> a better place to discuss this.
>
>
> >
>

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



Re: How is are Fields implemented?

2008-09-02 Thread bruno desthuilliers

On 2 sep, 13:50, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Hey Bruno,
>
> Thanks a lot! I read now 2 pages on metaclasses and I'm beginning to really
> feel I'm figuring it out...

If you only need to read 2 pages of doc to become proficient with
metaclasses, then your way smarter than I am.

> I'll read a bit more and once I start
> implementation and if I have any problems I'll ask back...

This discussion starts to be a bit OT here IMHO. This is more about
Python metaprogramming than about Django itself. comp.lang.py would be
a better place to discuss this.


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



Re: How is are Fields implemented?

2008-09-02 Thread bruno desthuilliers

On 2 sep, 20:46, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Now that I understand a lot better, I am implementing a class that inherits
> from type.

IOW, a metaclass.

>  So now I would like to create the instance

You mean the class ?-)

>  by writing:
>
> m = MyType(myClass.__name__, (), myClass.__dict__)

Not the most common way to use a metaclass, but technically legal...

> The problem is the fields in __dict__ are in arbitrary order, is there a way
> to get them in the order they appear in file?

You mean: in the class statement's body ? This will be the case for
Python3, but so far, you'll have to use the same trick as Django's
models to keep track of the order of fields instanciation. Have a look
at db/fields/__init__.py for the Field base class...



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



Re: problem with passing dict object to django template

2008-09-02 Thread bruno desthuilliers

On 2 sep, 20:22, Matt Berg <[EMAIL PROTECTED]> wrote:
> Sorry.
>
> Yes, in the template I do a loop...
>
> for crop in crops

Where do "crops" come from ? In your above code, you only returned the
ci dict, no t crops.

> In the view, I make an array ci (cropinfo).

It's actually a dict, not an array.

>  Each ci I append a new
> dict object (cd) which is associated with the crop id.
>
> In the template, I just want to loop through the crops

How do you make these crops available to your template ?

> and then
> display items in the embedded dict that are tied to the crop.id.

It would be simpler to just attach each 'cd' dict to your crop objects
in the view, then return the list of crops, ie:

def crop_info(season,crops):
hectares = 0
for c in crops:
hectares += c.hectares
cd = {}
cd['dap_kg_dollar'] = (season.DAP_local_fiftykg_price /
season.forex_input) / 50
cd['urea_kg_dollar'] = (season.urea_local_fiftykg_price /
season.forex_input) / 50
cd['seed_local_dollar'] = c.local_seed_price /
season.forex_input
cd['seed_improved_dollar'] = c.improved_seed_price /
season.forex_input
cd['total'] = (c.seed * cd['seed_improved_dollar']) +
(cd['urea_kg_dollar'] * c.urea)
c.crop_info = cd
return crops

Then in your template:

{% for crop in crops %}
{{crop.id}} : {{ crop.crop_info.total }}
{% endfor %}

HTH

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



Re: problem with passing dict object to django template

2008-09-02 Thread bruno desthuilliers



On 2 sep, 19:34, Matt Berg <[EMAIL PROTECTED]> wrote:
> Still new to django and python and have been struggling with the
> following.
>
> Basically, I want to pass the following dict object to a django
> template.
>
> def crop_info(season,crops):
> ci = {}
> cd = {}

Since you rebind cd later in the for loop, this first binding is
useless.

> dap_kg_dollar = 0
> urea_kg_dollar = 0
> seed_local_dollar = 0
> seed_improved_dollar = 0

None of these binding is used in the remaining code. Useless too.

> ci['hectares'] = 0
> for c in crops:
> cd = {}
> ci['hectares'] = ci['hectares'] + c.hectares

Use augmented assignement instead:
   ci['hectares'] += c.hectares

or better yet, use a local binding and store the result in ci after
the loop, this will save you len(crops) get/set access to ci.

> cd['dap_kg_dollar'] = (season.DAP_local_fiftykg_price /
> season.forex_input) / 50
> cd['urea_kg_dollar'] = (season.urea_local_fiftykg_price /
> season.forex_input) / 50
> cd['seed_local_dollar'] = c.local_seed_price /
> season.forex_input
> cd['seed_improved_dollar'] = c.improved_seed_price /
> season.forex_input
> cd['total'] = (c.seed * cd['seed_improved_dollar']) +
> (cd['urea_kg_dollar'] * c.urea)
> ci[c.id] = cd
> return ci

Looks like a lot of business logic for a view. Shouldn't this code
live somewhere in your models instead ?

> In my template, I want to be able to iterate through the crops with
> info like this:
>
> {{ ci.[crop.id].total }}

Where does this crop.id comes from ?

> This syntax does not work in the templates.  If I put in for example,
> ci.1.total I get the right result.  What's the proper way to do this
> within django.

Not enough information, sorry.


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



Re: How is are Fields implemented?

2008-09-02 Thread Abdallah El Guindy
Now that I understand a lot better, I am implementing a class that inherits
from type. So now I would like to create the instance by writing:

m = MyType(myClass.__name__, (), myClass.__dict__)

The problem is the fields in __dict__ are in arbitrary order, is there a way
to get them in the order they appear in file?

Thanks

On Tue, Sep 2, 2008 at 1:50 PM, Abdallah El Guindy <
[EMAIL PROTECTED]> wrote:

> Hey Bruno,
>
> Thanks a lot! I read now 2 pages on metaclasses and I'm beginning to really
> feel I'm figuring it out... I'll read a bit more and once I start
> implementation and if I have any problems I'll ask back...
>
> To anyone else curious about how the issue can be solved: the keyword is
> indeed "metclasses"
>
> Thanks for the help!
>
>
> On Tue, Sep 2, 2008 at 1:05 PM, bruno desthuilliers <
> [EMAIL PROTECTED]> wrote:
>
>>
>> On 2 sep, 10:33, "Abdallah El Guindy" <[EMAIL PROTECTED]>
>> wrote:
>> > Thank you very much for your reply. It seems that you understood my
>> question
>> > really well, but the answer is not as simple as I expected...
>>
>> ORMs are not a "simple" topic. Nor are advanced Python OO features.
>>
>> > I am trying to
>> > implement something similar.
>>
>> You mean, some way to specify a 'schema' for an object using 'smart'
>> properties ?
>>
>> > Could you explain a bit more (as I am no Python
>> > Guru)?
>>
>> If you don't have a good enough knowledge of Python's object model
>> (lookup rules, metaclasses, descriptor protocol etc), you'll have hard
>> time understanding any explanation. And if you have this knowledge,
>> you won't need my explanations anymore.
>>
>> IOW : first learn about the above topics (hint : all this is
>> documented on python.org, and you'll find help and more infos on
>> comp.lang.py).
>>
>> > Can you you point me to the part in the Django source that does that?
>>
>> django/db/models/base.py and django/db/models/fields/* should be a
>> good start.
>>
>> HTH
>> >>
>>
>

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



Re: getting max(field) with db-api

2008-09-02 Thread John M

i used that for mine and it always worked!  Mine was for a list of
child records by date, but child.objects.all()[0] always gave me the
most recent object.

J

On Sep 2, 7:23 am, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I want to perform a lookup an getting the object with the highest
> integer value.
> The Model looks something like this:
>
> MyModel:
>   name = 
>   number = models.PositiveIntegerField()
>
>   class Meta:
>      ordering = [-number]
>
> So I figured out this:
>
> highest = MyModel.objects.all()[0]
>
> Is there another, more elegant way like: highest =
> MyModel.object.filter(max(number)), so that I dont have to add the
> ordering-attribute in the medta-class?
>
> Thanks,
> Toni
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: name 'admin' is not defined

2008-09-02 Thread James Matthews
Also uncomment the admin.autodiscover() line. (If you are holding a svn
version)

On Tue, Sep 2, 2008 at 11:15 AM, Ronny Haryanto <[EMAIL PROTECTED]> wrote:

>
> On Wed, Sep 3, 2008 at 12:56 AM, Weber Sites <[EMAIL PROTECTED]>
> wrote:
> > I'm trying to follow the Tutorial02 and once i uncomment the admin
> > lines in urls.py i get :
> >
> > ImproperlyConfigured at /mysite/
> > Error while importing URLconf 'mysite.urls': name 'admin' is not defined
>
> This probably sounds silly, but since you don't give any code snippets
> then I can't be sure. Have you uncommented the import line:
>
>from django.contrib import admin
>
> in urls.py?
>
> Ronny
>
> >
>


-- 
http://www.goldwatches.com/

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



Re: problem with passing dict object to django template

2008-09-02 Thread Matt Berg

Sorry.

Yes, in the template I do a loop...

for crop in crops

In the view, I make an array ci (cropinfo).  Each ci I append a new
dict object (cd) which is associated with the crop id.

In the template, I just want to loop through the crops and then
display items in the embedded dict that are tied to the crop.id.

Hope this helps clarify it.

Thanks,

Matt



On Sep 2, 2:01 pm, David Zhou <[EMAIL PROTECTED]> wrote:
> On Sep 2, 2008, at 1:34 PM, Matt Berg wrote:
>
> > In my template, I want to be able to iterate through the crops with
> > info like this:
>
> > {{ ci.[crop.id].total }}
>
> Are you using this within another loop?  Where's crop.id coming from?
>
> ---
> David Zhou
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: name 'admin' is not defined

2008-09-02 Thread Ronny Haryanto

On Wed, Sep 3, 2008 at 12:56 AM, Weber Sites <[EMAIL PROTECTED]> wrote:
> I'm trying to follow the Tutorial02 and once i uncomment the admin
> lines in urls.py i get :
>
> ImproperlyConfigured at /mysite/
> Error while importing URLconf 'mysite.urls': name 'admin' is not defined

This probably sounds silly, but since you don't give any code snippets
then I can't be sure. Have you uncommented the import line:

from django.contrib import admin

in urls.py?

Ronny

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



Re: problem with passing dict object to django template

2008-09-02 Thread David Zhou


On Sep 2, 2008, at 1:34 PM, Matt Berg wrote:

> In my template, I want to be able to iterate through the crops with
> info like this:
>
> {{ ci.[crop.id].total }}

Are you using this within another loop?  Where's crop.id coming from?




---
David Zhou
[EMAIL PROTECTED]




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



Re: Initial values in form fields

2008-09-02 Thread Daniel Roseman

On Sep 2, 6:10 pm, cArkraus <[EMAIL PROTECTED]> wrote:
> Hey everyone,
>
> am pretty new to Django and Python in general.
> I seem not be able to let the 'initial' value of a form-field be
> calculated by its parent form.
>
> I'd like to do sth like this:
>
> class AbstractForm(forms.Form):
> some_attr = "foo"
>
> def some_method(self):
> if self.some_attr == "foo": return "foo"
> return "Something else..."
>
> some_field = forms.CharField(initial=self.some_method())
>
> ..but obviously I cant access 'self' when declaring some_field.. and
> obviously I have yet to learn a lot about Python oop :)
>
> Fyi. I do not want to initiate form defaults like
> f = MyForm(initial=...) in my views since I'd have to repeat that in
> each view.
>
> I'd rather do things like this lateron:
> class ConcreteForm(AbstractForm):
> some_attr = "bar"
>
> Somebody willing to enlighten me?
>
> Thx a lot & cheers
> carsten

I'm not sure I really understand what you want to do here, but I think
the best thing would be for you to override the __init__() method.

class AbstractForm(forms.Form):
  def __init__(self, *args, **kwargs):
  super(AbstractForm, self).__init__(*args, **kwargs)
  self.fields['some_field'].initial = self.some_method()

If you need an __init__ in the child form as well, don't forget to
call super(ConcreteForm, self).__init__() again there.

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



Re: Random HTTP Error 500's - ImproperlyConfigured

2008-09-02 Thread James Matthews
Is it possible that some form of server security is stripping them out?

On Tue, Sep 2, 2008 at 10:28 AM, cwurld <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> My site has recently starting generating a lot of HTTP Error 500's.
> The traceback is always:
>
> ImproperlyConfigured: Error importing request processor module xxx:
> "No module named yyy"
>
> where xxx and yyy are random modules. I know these modules are present
> and working correctly. Most of the time all the modules load without
> errors.
>
> Also, it does not seem to matter what page is being requested.
>
> I am using revision 7153.
>
> Thanks,
> Chuck
>
>
>
> >
>


-- 
http://www.goldwatches.com/

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



name 'admin' is not defined

2008-09-02 Thread Weber Sites

Hi

I'm trying to follow the Tutorial02 and once i uncomment the admin
lines in urls.py i get :

ImproperlyConfigured at /mysite/
Error while importing URLconf 'mysite.urls': name 'admin' is not defined

berber

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



Re: ModelForm, images and exclude

2008-09-02 Thread flynnguy

Ok, some experimentation has yielded that the problem lies here:
def photoDir(self, filename):
"Callable method used to set directory of media below"
return os.path.join('pet_photos', str(self.pet.id), filename)
Basically what seems to be happening is that it tries to save the file
and then continue on to the post save(commit=False) bits.
Unfortunately in my case, when saving the file, it looks at the pet.id
so I can save the image in say /media/pet_photos/1/ so I have all the
photos related to a pet in the same directory but I haven't set it
yet.

Anyone have any suggestions on a way around this? I was thinking of
having a hidden field but still changing it post save(commit=False) to
avoid a user changing it but that just seems unelegant and I also
can't see a way to set the default value for the hidden field. (adding
defalt=whatever on the forms.CharField() doesn't seem to work)
-Chris

On Sep 2, 12:35 pm, flynnguy <[EMAIL PROTECTED]> wrote:
> I tried the id thing which didn't seem to work but then when I tried
> the null thing I think I found out what is going on. It looks like the
> callable save bit for the photo is not getting a pet id so it doesn't
> know where to save it. Of course this is just a guess and I have no
> proof... some more fiddling is needed.
> -Chris
>
> On Sep 2, 12:21 pm, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>
> > On Sep 2, 4:04 pm, flynnguy <[EMAIL PROTECTED]> wrote:
>
> > > Found out what was causing the error but not why...
>
> > > It seems that when I tell my model to not exclude the "pet" field,
> > > that everything works fine. (ie, I select a pet from the dropdown)
> > > When I add it to the exclude list and try to set it manually I get an
> > > error.
>
> > > What seems to work is allowing the pet selection but then setting it
> > > after I do save(commit=False). I'm trying to set it up as a hidden
> > > field but I keep getting that it's a required field. I can't seem to
> > > figure out how to set a default value. Any ideas why this might be
> > > happening?
> > > -Chris
>
> > You could try this;
> >  added_photo.pet_id = pet.id
>
> > That might work. Otherwise, try allowing null=True in the pet FK
> > field, and doing form.save() then adding the pet then saving again.
> > --
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dispatch.fcgi as text

2008-09-02 Thread James Matthews
Also make sure to set the rewrite handle. On my shared host you need to
enable fcgi then have the dispatch.fcgi in your web root.

On Tue, Sep 2, 2008 at 8:31 AM, Milan Andric <[EMAIL PROTECTED]> wrote:

>
> On Mon, Sep 1, 2008 at 7:19 PM, Ronaldo Z. Afonso
> <[EMAIL PROTECTED]> wrote:
> >
> > Hi everybody,
> >
> > I'm running Django on a shared-hosting provider with Apache and I walked
> > through the documentation about FastCGI of the Django website but when I
> > try to access some page of my web site, instead of seen the html
> > rendered I just see the dispatch.fcgi as text. Does anyone can help me?
> >
> > ps) My dispatch.fcgi is executable.
> >
>
> Ronaldo,
>
> You probably don't have the fastcgi module activated.  In your apache
> or .htaccess config make sure you have something like AddHandler
> fastcgi-script .fcgi .  If you have the AddHandler in your .htaccess
> then maybe Apache is overriding that or it's not in your vhost config.
>  AllowOverride All is another important Apache directive that allows
> you to use AddHandler in your .htaccess, you can check that also.
>
> Are you running your own apache or just using a service?  If you are
> using a service then they may have better instructions about setting
> it up.  If you still can't get it to work then post some configuration
> information, like your .htaccess and vhost config.
>
> --
> Milan
>
> >
>


-- 
http://www.goldwatches.com/

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



problem with passing dict object to django template

2008-09-02 Thread Matt Berg

Still new to django and python and have been struggling with the
following.

Basically, I want to pass the following dict object to a django
template.

def crop_info(season,crops):
ci = {}
cd = {}
dap_kg_dollar = 0
urea_kg_dollar = 0
seed_local_dollar = 0
seed_improved_dollar = 0
ci['hectares'] = 0
for c in crops:
cd = {}
ci['hectares'] = ci['hectares'] + c.hectares
cd['dap_kg_dollar'] = (season.DAP_local_fiftykg_price /
season.forex_input) / 50
cd['urea_kg_dollar'] = (season.urea_local_fiftykg_price /
season.forex_input) / 50
cd['seed_local_dollar'] = c.local_seed_price /
season.forex_input
cd['seed_improved_dollar'] = c.improved_seed_price /
season.forex_input
cd['total'] = (c.seed * cd['seed_improved_dollar']) +
(cd['urea_kg_dollar'] * c.urea)
ci[c.id] = cd
return ci

In my template, I want to be able to iterate through the crops with
info like this:

{{ ci.[crop.id].total }}

This syntax does not work in the templates.  If I put in for example,
ci.1.total I get the right result.  What's the proper way to do this
within django.

Greatly appreciate any help on this.

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



Random HTTP Error 500's - ImproperlyConfigured

2008-09-02 Thread cwurld

Hi,

My site has recently starting generating a lot of HTTP Error 500's.
The traceback is always:

ImproperlyConfigured: Error importing request processor module xxx:
"No module named yyy"

where xxx and yyy are random modules. I know these modules are present
and working correctly. Most of the time all the modules load without
errors.

Also, it does not seem to matter what page is being requested.

I am using revision 7153.

Thanks,
Chuck



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



Initial values in form fields

2008-09-02 Thread cArkraus

Hey everyone,

am pretty new to Django and Python in general.
I seem not be able to let the 'initial' value of a form-field be
calculated by its parent form.

I'd like to do sth like this:

class AbstractForm(forms.Form):
some_attr = "foo"

def some_method(self):
if self.some_attr == "foo": return "foo"
return "Something else..."

some_field = forms.CharField(initial=self.some_method())

..but obviously I cant access 'self' when declaring some_field.. and
obviously I have yet to learn a lot about Python oop :)

Fyi. I do not want to initiate form defaults like
f = MyForm(initial=...) in my views since I'd have to repeat that in
each view.

I'd rather do things like this lateron:
class ConcreteForm(AbstractForm):
some_attr = "bar"

Somebody willing to enlighten me?

Thx a lot & cheers
carsten


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



Re: Problem with 404 page

2008-09-02 Thread marsii

Hi!

> You are responsible for creating both 404.html and 500.html templates.  See:
> http://docs.djangoproject.com/en/dev/topics/http/views/#customizing-e...
> Karen

Thanks!

regards
Markku

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



Re: utf8 works on my dev server but not on my production server

2008-09-02 Thread n00m


>>> s = 'Rémi'
>>> type(s)

>>> s.decode('utf-8')
Traceback (most recent call last):
  File "", line 1, in ?
  File "encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode bytes in
position 1-3:
invalid data


And why you surprized on that?
(a non-UTF-8 terminal as Karen mentioned)
It just means that "s" is NOT a valid sequence of bytes of UTF-8 data.
The same case when you're trying to decode (FROM UTF-8) a data
retrieved
from your mysql table.

I don't know MySQL but what if your data got messed and corrupted
after
you applied all those "ALTER...CONVERT TO CHARACTER SET utf8
collate.."
statements against your tables?

If you show to us *a binary/hex representation* of some "French" word
from
your table it could clear up everything.

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



Re: define "_default_manager" and the admin-interface

2008-09-02 Thread Brett H

As far as I can see in principle you would want to leave the live
manager first as your default manager and then override it in your
admin class as the exception - something like this:

class EntryAdmin(admin.ModelAdmin):
...
manager = Entry.objects

But admin needs patching to make that work which is an open ticket
http://code.djangoproject.com/ticket/7510.

At the moment you would need to override every method in
admin.ModelAdmin that gets the default manager, so it's easier at the
moment just to make the standard manager the default instead of your
custom manager.

I'm writing a blog on this book - but I am only just finishing up
chapter 5 which first defines the custom manager.
http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm, images and exclude

2008-09-02 Thread flynnguy

I tried the id thing which didn't seem to work but then when I tried
the null thing I think I found out what is going on. It looks like the
callable save bit for the photo is not getting a pet id so it doesn't
know where to save it. Of course this is just a guess and I have no
proof... some more fiddling is needed.
-Chris

On Sep 2, 12:21 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 2, 4:04 pm, flynnguy <[EMAIL PROTECTED]> wrote:
>
> > Found out what was causing the error but not why...
>
> > It seems that when I tell my model to not exclude the "pet" field,
> > that everything works fine. (ie, I select a pet from the dropdown)
> > When I add it to the exclude list and try to set it manually I get an
> > error.
>
> > What seems to work is allowing the pet selection but then setting it
> > after I do save(commit=False). I'm trying to set it up as a hidden
> > field but I keep getting that it's a required field. I can't seem to
> > figure out how to set a default value. Any ideas why this might be
> > happening?
> > -Chris
>
> You could try this;
>  added_photo.pet_id = pet.id
>
> That might work. Otherwise, try allowing null=True in the pet FK
> field, and doing form.save() then adding the pet then saving again.
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm, images and exclude

2008-09-02 Thread Daniel Roseman

On Sep 2, 4:04 pm, flynnguy <[EMAIL PROTECTED]> wrote:
> Found out what was causing the error but not why...
>
> It seems that when I tell my model to not exclude the "pet" field,
> that everything works fine. (ie, I select a pet from the dropdown)
> When I add it to the exclude list and try to set it manually I get an
> error.
>
> What seems to work is allowing the pet selection but then setting it
> after I do save(commit=False). I'm trying to set it up as a hidden
> field but I keep getting that it's a required field. I can't seem to
> figure out how to set a default value. Any ideas why this might be
> happening?
> -Chris

You could try this;
 added_photo.pet_id = pet.id

That might work. Otherwise, try allowing null=True in the pet FK
field, and doing form.save() then adding the pet then saving again.
--
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DjangoCon/1.0 Release Party -- Need a Ride!

2008-09-02 Thread Derek Payton

Hey guys,

For those of you going to DjangoCon...

My boss and I are attending DjangoCon this weekend, and we're both
super excited. Thing is, however, he's unable to attend the 1.0
release party, and I'd really like to go. Since I don't drive and he's
my only ride, this leaves me with the task of finding a ride home
after the party or I won't be able to attend.

So would anyone be willing and able to give me a ride home after the
release party? I live in Campbell, about 20 minutes South of Mountain
View. I realize there will be a lot of out-of-towners, so if no one's
able, it's no problem.

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



Re: S3 tutorial for File Storage Refactor?

2008-09-02 Thread shadfc

To fix the corrupt images error, add
content.open()
to the top of _save() on the S3Storage class (or at least before the
chunks() or read() calls).  This basically causes a seek(0) on
content.  I think perhaps some of the image validation reads part of
the file and doesn't reset the pointer back to the beginning.

Jay

On Sep 1, 10:40 am, Ramdas S <[EMAIL PROTECTED]> wrote:
> David,
>
> I think this is still not fixed. I am getting the same errors
>
> R
>
> On Aug 25, 2:02 pm, David Larlet <[EMAIL PROTECTED]> wrote:
>
> > Le 20 août 08 à 17:56, shadfc a écrit :
>
> > > With the code from the django-storages you referenced installed
> > > somewhere on PYTHONPATH, its as easy as setting a few things in your
> > > settings.py.  You can see the docs for the code at
> > >http://code.larlet.fr/doc/django-s3-storage.html.  Put the Required
> > > and Optional (if you want it, obviously) stuff in your settings.py and
> > > fill in the appropriate values for yourS3account.
>
> > > Now, assuming those settings are all correct, all of your FileFields
> > > (and thus, ImageFields) should store toS3into the bucket you set.
> > > You can continue to use upload_to to prefix the filename within the
> > > bucket.
>
> > > Now, I've noticed a few bugs, both of which I've notified David (the
> > > author) of:
> > > 1) if you call object.filefield.size, this code will download the
> > > entire file fromS3just to calculate the size. This happens because
> > > of the construction of the _open() method on the S3Storage class.  It
> > > should not make theS3get call (which downloads the file).  The
> > > workaround for now is not to use the size property with this code, but
> > > the more permanent fix is to delay reading of the file fromS3until
> > > read() is called on a S3StorageFile object.
> > > 2) I cannot get images to store correctly toS3when using an
> > > ImageField. They appear in the bucket with a small filesize change,
> > > but no software I have will recognize them as valid images.  Storing
> > > images (and any other file) via a FileField works just fine and the
> > > files are not corrupted.  Strangely, storing images via ImageField on
> > > the FileSystemStorage backend works just fine, so it only seems to be
> > > the combination of an ImageField while using thisS3backend that is
> > > the problem.  I am not sure where the bug in this is.  If you give it
> > > a try, see if you can verify this bug for me.
>
> > > Jay
>
> > Hi Jay,
>
> > I plan to work on this tonight because that's clearly a blocking
> > point. Thanks for reporting those bugs.
>
> > Best,
> > David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL configuration with Django deployed in a subdirectory

2008-09-02 Thread bryanzera

I've figured it out.

.htaccess above my subdirectory was trying to munge my URLs rather
than letting Django take care of them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL configuration with Django deployed in a subdirectory

2008-09-02 Thread bryanzera

> You don't say how you are deploying the site.

mod_python/apache2


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



day is out of range for month

2008-09-02 Thread Xiong Chiamiov

On a site of ours, we got a 500 on Aug 31 with the error:

ImproperlyConfigured: Error while importing URLconf 'ee_website.urls':
day is out of range for month

from this line:

announcements = {'queryset':
Announcement.objects.filter(active=True,expire_date__gt=datetime.today()).order_by('-
publish_date')}

Commenting it out, and the lines that depended on it, removed the
problem.
Reverting those changes on the 2nd produced a working site.

I'm not in charge of the servers, but I believe that this one is
running an svn build that's no more than a few weeks old.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dispatch.fcgi as text

2008-09-02 Thread Milan Andric

On Mon, Sep 1, 2008 at 7:19 PM, Ronaldo Z. Afonso
<[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> I'm running Django on a shared-hosting provider with Apache and I walked
> through the documentation about FastCGI of the Django website but when I
> try to access some page of my web site, instead of seen the html
> rendered I just see the dispatch.fcgi as text. Does anyone can help me?
>
> ps) My dispatch.fcgi is executable.
>

Ronaldo,

You probably don't have the fastcgi module activated.  In your apache
or .htaccess config make sure you have something like AddHandler
fastcgi-script .fcgi .  If you have the AddHandler in your .htaccess
then maybe Apache is overriding that or it's not in your vhost config.
 AllowOverride All is another important Apache directive that allows
you to use AddHandler in your .htaccess, you can check that also.

Are you running your own apache or just using a service?  If you are
using a service then they may have better instructions about setting
it up.  If you still can't get it to work then post some configuration
information, like your .htaccess and vhost config.

--
Milan

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



Re: getting max(field) with db-api

2008-09-02 Thread mwebs

Oh thanks,

I think I have overlooked it :-)

On 2 Sep., 16:35, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-09-02, o godz. 16:23, przez mwebs:
>
>
>
>
>
> > Hello,
>
> > I want to perform a lookup an getting the object with the highest
> > integer value.
> > The Model looks something like this:
>
> > MyModel:
> >  name = 
> >  number = models.PositiveIntegerField()
>
> >  class Meta:
> > ordering = [-number]
>
> > So I figured out this:
>
> > highest = MyModel.objects.all()[0]
>
> > Is there another, more elegant way like: highest =
> > MyModel.object.filter(max(number)), so that I dont have to add the
> > ordering-attribute in the medta-class?
>
> Sure, you can always specify ordering using order_by(). Ordering
> defines default ordering, where no ordering is specified.
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R&D, Redefine
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm, images and exclude

2008-09-02 Thread flynnguy

Found out what was causing the error but not why...

It seems that when I tell my model to not exclude the "pet" field,
that everything works fine. (ie, I select a pet from the dropdown)
When I add it to the exclude list and try to set it manually I get an
error.

What seems to work is allowing the pet selection but then setting it
after I do save(commit=False). I'm trying to set it up as a hidden
field but I keep getting that it's a required field. I can't seem to
figure out how to set a default value. Any ideas why this might be
happening?
-Chris

On Sep 2, 9:52 am, TiNo <[EMAIL PROTECTED]> wrote:
> You could check with the pdb debugger where the error is returned, and maybe
> you can also see what field is causing the problem.
>
> On Tue, Sep 2, 2008 at 3:34 PM, flynnguy <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the tips, I did know about the get_object_or_404 and had
> > that there originally but I wanted to rule things out and was hoping
> > if the pet_id didn't exist, that would throw an error I'm used to
> > seeing. Unfortunately that seems to not be the problem. I did make the
> > changes regarding the Media.views field but that didn't seem to make
> > any difference but does clean the code up a bit. Thanks for your help.
>
> > From the error it looks like a related field doesn't exist but I can't
> > tell what field it's complaining about. Usually the error messages are
> > helpful, this time, not so much.
> > -Chris
>
> > On Aug 31, 12:37 pm, TiNo <[EMAIL PROTECTED]> wrote:
> > > On Fri, Aug 29, 2008 at 6:37 PM, flynnguy <[EMAIL PROTECTED]> wrote:
> > > > ..
> > > > However there are certain fields I want to set manually so I tried
> > > > this:
> > > > class AddPhotoForm(ModelForm):
> > > >    class Meta:
> > > >        model = Media
> > > >        exclude = ('type', 'pet', 'views')
>
> > > > def add_pet_photo(request, pet_id):
> > > >    pet = Pet.objects.get(id=pet_id)
>
> > > It is possible a pet with this id does not exist, so use
> > get_object_or_404,
> > > or catch the DoesNotExist here and raise a 404.
>
> > > >    if request.method == 'POST':
> > > >        form = AddPhotoForm(data=request.POST, files=request.FILES)
> > > >        if form.is_valid():
> > > >            added_photo = form.save(commit=False)
> > > >            added_photo.pet = pet
> > > >            added_photo.type = 'P'
> > > >            added_photo.views = 0 # this is a zero and is used as a
> > > > counter
>
> > > If you add 'blank=True' to 'views = models.IntegerField(default=0)' in
> > your
> > > model, you don't need to add the last line. You also don't need the
> > > 'self.views = 0' in the save method below:
>
> > > >    def save(self):
> > > >        if not self.id:
> > > >            self.created = datetime.datetime.today()
> > > >            self.views = 0
> > > >        self.updated = datetime.datetime.today()
> > > >        self.thumbnail = create_thumbnail(self.image, THUMB_WIDTH,
> > > > THUMB_HEIGHT)
> > > >        super(Media, self).save()
>
> > > Don't think it will solve your problem, some tips though.
>
> > > TiNo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: getting max(field) with db-api

2008-09-02 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-09-02, o godz. 16:23, przez mwebs:

>
> Hello,
>
> I want to perform a lookup an getting the object with the highest
> integer value.
> The Model looks something like this:
>
> MyModel:
>  name = 
>  number = models.PositiveIntegerField()
>
>  class Meta:
> ordering = [-number]
>
>
> So I figured out this:
>
> highest = MyModel.objects.all()[0]
>
> Is there another, more elegant way like: highest =
> MyModel.object.filter(max(number)), so that I dont have to add the
> ordering-attribute in the medta-class?


Sure, you can always specify ordering using order_by(). Ordering  
defines default ordering, where no ordering is specified.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[EMAIL PROTECTED]


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



getting max(field) with db-api

2008-09-02 Thread mwebs

Hello,

I want to perform a lookup an getting the object with the highest
integer value.
The Model looks something like this:

MyModel:
  name = 
  number = models.PositiveIntegerField()

  class Meta:
 ordering = [-number]


So I figured out this:

highest = MyModel.objects.all()[0]

Is there another, more elegant way like: highest =
MyModel.object.filter(max(number)), so that I dont have to add the
ordering-attribute in the medta-class?

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



Re: Cannot get user profile working.

2008-09-02 Thread Alex

Thanks, worked perfectly.

Not sure if it's just me and my lack of sleep or the docs aren't that
clear on this item.  I didn't see much regarding this on the Internet
so there must not be scores of others making the same mistake.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Rebuilding an application reusing the business logic

2008-09-02 Thread Dick Kniep

Hi list,

This is my first post to this mailinglist, We have not used Django sofar, but 
we are considering Django to rewrite a big Python/wxPython application, reusing 
the businesslogic all written in Python.

We have built our own connection the the database, which delivers a list of 
objects. Each object can be a row in the database (or something else), and 
methods apply to those objects, effectively implementing the businesslogic of 
the application.

We thought that we could use Pyro (Python Remote Objects pyro.sourceforge.net) 
to connect to the businesslogic. However, Django uses its own method of SQL 
invocation. So the question is simply if it is possible to use Django for this 
purpose, or that it is necessary to (re)write large chunks of code.

Possibly this is all very clear to you, in that case I apologize for my 
ignorance.

Cheers,
Dick Kniep

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



Re: ModelForm, images and exclude

2008-09-02 Thread TiNo
You could check with the pdb debugger where the error is returned, and maybe
you can also see what field is causing the problem.

On Tue, Sep 2, 2008 at 3:34 PM, flynnguy <[EMAIL PROTECTED]> wrote:

>
> Thanks for the tips, I did know about the get_object_or_404 and had
> that there originally but I wanted to rule things out and was hoping
> if the pet_id didn't exist, that would throw an error I'm used to
> seeing. Unfortunately that seems to not be the problem. I did make the
> changes regarding the Media.views field but that didn't seem to make
> any difference but does clean the code up a bit. Thanks for your help.
>
> From the error it looks like a related field doesn't exist but I can't
> tell what field it's complaining about. Usually the error messages are
> helpful, this time, not so much.
> -Chris
>
> On Aug 31, 12:37 pm, TiNo <[EMAIL PROTECTED]> wrote:
> > On Fri, Aug 29, 2008 at 6:37 PM, flynnguy <[EMAIL PROTECTED]> wrote:
> > > ..
> > > However there are certain fields I want to set manually so I tried
> > > this:
> > > class AddPhotoForm(ModelForm):
> > >class Meta:
> > >model = Media
> > >exclude = ('type', 'pet', 'views')
> >
> > > def add_pet_photo(request, pet_id):
> > >pet = Pet.objects.get(id=pet_id)
> >
> > It is possible a pet with this id does not exist, so use
> get_object_or_404,
> > or catch the DoesNotExist here and raise a 404.
> >
> >
> >
> > >if request.method == 'POST':
> > >form = AddPhotoForm(data=request.POST, files=request.FILES)
> > >if form.is_valid():
> > >added_photo = form.save(commit=False)
> > >added_photo.pet = pet
> > >added_photo.type = 'P'
> > >added_photo.views = 0 # this is a zero and is used as a
> > > counter
> >
> > If you add 'blank=True' to 'views = models.IntegerField(default=0)' in
> your
> > model, you don't need to add the last line. You also don't need the
> > 'self.views = 0' in the save method below:
> >
> >
> >
> > >def save(self):
> > >if not self.id:
> > >self.created = datetime.datetime.today()
> > >self.views = 0
> > >self.updated = datetime.datetime.today()
> > >self.thumbnail = create_thumbnail(self.image, THUMB_WIDTH,
> > > THUMB_HEIGHT)
> > >super(Media, self).save()
> >
> > Don't think it will solve your problem, some tips though.
> >
> > TiNo
> >
>

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



Re: ModelForm, images and exclude

2008-09-02 Thread flynnguy

Thanks for the tips, I did know about the get_object_or_404 and had
that there originally but I wanted to rule things out and was hoping
if the pet_id didn't exist, that would throw an error I'm used to
seeing. Unfortunately that seems to not be the problem. I did make the
changes regarding the Media.views field but that didn't seem to make
any difference but does clean the code up a bit. Thanks for your help.

>From the error it looks like a related field doesn't exist but I can't
tell what field it's complaining about. Usually the error messages are
helpful, this time, not so much.
-Chris

On Aug 31, 12:37 pm, TiNo <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 29, 2008 at 6:37 PM, flynnguy <[EMAIL PROTECTED]> wrote:
> > ..
> > However there are certain fields I want to set manually so I tried
> > this:
> > class AddPhotoForm(ModelForm):
> >    class Meta:
> >        model = Media
> >        exclude = ('type', 'pet', 'views')
>
> > def add_pet_photo(request, pet_id):
> >    pet = Pet.objects.get(id=pet_id)
>
> It is possible a pet with this id does not exist, so use get_object_or_404,
> or catch the DoesNotExist here and raise a 404.
>
>
>
> >    if request.method == 'POST':
> >        form = AddPhotoForm(data=request.POST, files=request.FILES)
> >        if form.is_valid():
> >            added_photo = form.save(commit=False)
> >            added_photo.pet = pet
> >            added_photo.type = 'P'
> >            added_photo.views = 0 # this is a zero and is used as a
> > counter
>
> If you add 'blank=True' to 'views = models.IntegerField(default=0)' in your
> model, you don't need to add the last line. You also don't need the
> 'self.views = 0' in the save method below:
>
>
>
> >    def save(self):
> >        if not self.id:
> >            self.created = datetime.datetime.today()
> >            self.views = 0
> >        self.updated = datetime.datetime.today()
> >        self.thumbnail = create_thumbnail(self.image, THUMB_WIDTH,
> > THUMB_HEIGHT)
> >        super(Media, self).save()
>
> Don't think it will solve your problem, some tips though.
>
> TiNo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User groups and permissions

2008-09-02 Thread caphun

In case anyone was wondering; I created a ticket in the Django bug
tracker and _finally_ got a response from telenieko - thanks!

quote:

I'd guess this would either mean:

* Field/Row level permissions, which are not (yet) implemented.
* Provide more fine-grained permissions.

So, it's not really a bug, but a feature request. You could say it's a
gotcha if you wish ;)

I'll mark this post-1.0; But it's likely to die as "invalid" and maybe
opened as "Provide finer control in contrib.auth" when the above gets
implemented ;)

unquote.

So, here's hoping it's not at the bottom of the list!


09/01/08 10:38:23 changed by caphun ¶

On Aug 31, 9:17 pm, Ca Phun Ung <[EMAIL PROTECTED]> wrote:
> Hello fellow Djangonauts,
>
> I hit a problem with user permissions within the Django admin area. The
> other day I gave a user add/edit/delete user permissions so that they
> could manage staff access on the websites. However, in doing this that
> particular user is now able to create other users with greater
> permissions than himself, even promoting others to superuser status.
> Furthermore that user could also turn himself super by editing his own
> profile. Has anyone come across this problem? Is there a workaround? I
> assume there is a way to lock user permissions so one cannot promote
> oneself or others beyond ones allocated permission level?
>
> Thanks.
>
> -- Ca-Phun Ung
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using subclass of RequestContext in generic views?

2008-09-02 Thread Tim Chase

>> My subclassed RequestContext object plans to intercept the 
>> Context.__getitem__ call (wherein redaction will hopefully happen 
>> in my custom subclass), and thus needs to be the actual object, 
>> not just a dict-like object merged into the existing 
>> RequestContext object.
> 
> Thinking sideways, do you really need to intercept the Context
> __getitem__, or can you just add an object to the context with a custom
> __getitem__ instead?  Your templates would need to do {{ someobj.foo }}
> instead of {{ foo }}.
> 
> The above would work if you just want to add computed items to the
> context, but obviously won't work if for some reason you want to alter
> or filter out pre-existing items from the context.

The aforementioned "redaction" is indeed "alter[ing] or 
filter[ing] out pre-existing items from the context".

The catch is that my redaction needs to know the request context 
information (is it an HTTPS connection, and is this user able to 
see the info in question).  It makes a check based on the 
internal Meta class of my models, to see if a field should be 
redacted.  Thus, my class might look something like

   class Person(Model):
 name = CharField(...)
 ssn = CharField(...)
 dob = DateField(...)
 ccn = CharField(...)
 class Meta:
   # redact the social-security # and credit-card number
   redacted_fields = set(['ssn', 'ccn'])

The "ssn" field and "ccn" field should only ever be shown to 
authenticated users with the defined permissions, over SSL 
connections.  Ideally, this redaction would take place before the 
values ever get to the template, so template authors can't 
accidentally leak sensitive information (by forgetting a filter). 
  I'd also like to have it as DRY as possible, so developers 
don't have to remember to put redaction in everywhere, even if 
it's just one per URL entry.

It can't readily go in the URLs.py because it needs the request 
info to know whether to redact or not -- the first point of 
interception is in the view.  However, to take advantage of 
generic views, I either need to tweak the RequestContext object 
to use my own (and then get the generic views to use that new 
object), or to copy the existing generic-view code-base and then 
edit it to do the redaction within.

-tim





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



ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

2008-09-02 Thread Weber Sites

I'm using LAMP with Django 1.0 B2 and mod_python.
going through http://www.djangobook.com/en/1.0/chapter20/

I get : ImportError: Settings cannot be imported, because environment
variable DJANGO_SETTINGS_MODULE is undefined.

in my apache2 httpd-vhosts.conf i have


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonPath "['/home/WWW2'] + sys.path"
PythonDebug On
#PythonOption django.root /mysite
#SetEnv PYTHON_EGG_CACHE "/tmp/pythoneggs"


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



Re: (Solved) Re: Using full SQL LIKE matching in database operations

2008-09-02 Thread Djn

Right, I've managed to confuse myself at some point earlier and it
shows.

What I have wanted to use isn't "LIKE" but "SIMILAR TO".
The actual, working, code looks similar to
wordGenome.objects.extra(where=["word similar to %s"],
params=[subword] )

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



Re: is_ajax and YUI uploader: works on MAC, but 403 on Windows

2008-09-02 Thread tom

Because of a known Flash bug, the Uploader running in Firefox in
Windows does not send the correct cookies with the upload; instead of
sending Firefox cookies, it sends Internet Explorer’s cookies for the
respective domain. As a workaround, we suggest either using a
cookieless upload method or appending document.cookie to the upload
request.



On 26 Aug., 13:15, tom <[EMAIL PROTECTED]> wrote:
> Hi,
>
> We are using csrf together with ajax 
> (Patch:http://code.djangoproject.com/ticket/8127).
> For content uploading we are using the YUI uploader but we are getting
> an HTTP403 Error when we try to upload with windows (ie 7 and also
> firefox 3), but there are no problems with safari and firefox on a
> mac.
>
> Does anyone has some suggestion where to look at? (We do not have the
> option to migrate to django 1.0 beta yet)
>
> cheers, tom
>
> P.S.:
> our setup
> django version: 0.97-pre-SVN-unknown
>
> svn info:
> Path: .
> URL:http://code.djangoproject.com/svn/django/trunk
> Repository Root:http://code.djangoproject.com/svn
> Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
> Revision: 7920
> Node Kind: directory
> Schedule: normal
> Last Changed Author: russellm
> Last Changed Rev: 7917
> Last Changed Date: 2008-07-13 14:16:11 +0200 (So, 13 Jul 2008)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using subclass of RequestContext in generic views?

2008-09-02 Thread Chris Emerson

Hi Tim,

On Mon, Sep 01, 2008 at 10:04:36AM -0500, Tim Chase wrote:
> My subclassed RequestContext object plans to intercept the 
> Context.__getitem__ call (wherein redaction will hopefully happen 
> in my custom subclass), and thus needs to be the actual object, 
> not just a dict-like object merged into the existing 
> RequestContext object.

Thinking sideways, do you really need to intercept the Context
__getitem__, or can you just add an object to the context with a custom
__getitem__ instead?  Your templates would need to do {{ someobj.foo }}
instead of {{ foo }}.

The above would work if you just want to add computed items to the
context, but obviously won't work if for some reason you want to alter
or filter out pre-existing items from the context.

Cheers,

Chris

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



(Solved) Re: Using full SQL LIKE matching in database operations

2008-09-02 Thread Djn

On Sep 1, 7:13 pm, Djn <[EMAIL PROTECTED]> wrote:
> I'm in the process of moving an existing app over to python and
> Django, and ran into one snag I haven't been able to find any comments
> on.
>
> Basically, I have objects that describe themselves as an SQL-style
> pattern (they represent small chunks of possible patterns from DNA, so
> things like "GTGCGG_[AT]"). There's also a table with a word field,
> and I'd like to do the equivalent of "SELECT * FROM  word_genome WHERE
> word LIKE 'GTGCGG_[AT]' .
>
> Is there any way to either turn autoescaping off for single queries
> (which would make it trivial to mangle __contains or something to work
> for me), or have I overlooked any other obvious possibilities?
>
> Rewriting to use __regex is possible, but I'd rather avoid it.
>

I found a solution, so I'll just reply to myself in case someone finds
this post later and wonders.
The answer is indeed another obvious possibility: The .extra() method
in the model class is made for things like this.
To be exact, wordGenome.objects.extra(where=[ "word like
'GTGCGG_[AT]'"]) does what I needed.


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



Handling 'unique'

2008-09-02 Thread David

Hi,

when setting (for example)

name = models.CharField('Name', max_length=50, unique = True)

How does one go about handling the exception if a name is entered that
already exists in the database?

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



Re: Custom Comment Form - post_comment()

2008-09-02 Thread Hanne Moa

On Tue, Sep 2, 2008 at 12:29 PM, Thejaswi Puthraya
<[EMAIL PROTECTED]> wrote:
> For any general web-application, every user is expected to enter his
> details like first name and last name so it's not a usual case to have
> both of them empty.

I have several projects written in Django up and running right now,
none of them (even the half or so that uses django.contrib.auth) uses
the first_name and last_name for anything. If I need to have more than
a *username* I use a field display_name in the profile-model. This
elegantly gets around internationalization-problems: the japanese and
hungarians get to see their own names as they expect them to be seen
(family name first), to the limits of UTF-8, and even people like
Banksy or Madonna or Prince are allowed to use the service (not that
any of them ever would, mind). Most web services/sites, social or not,
ask far more than is necessary anyway, but then I am a recovering
cypherpunk... If the info isn't there, it can't be leaked.

For the record, I'm European, and there are European countries where
you need a license from the state and a certificate from the police to
be allowed to build a database of people, if the people in question
give the information freely or not. Furthermore, you must have a
system in place for the people in question to be allowed to correct
and/or remove their own info. Not needed with just a username =)


HM, in CYA-mode

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



Re: How is are Fields implemented?

2008-09-02 Thread Abdallah El Guindy
Hey Bruno,

Thanks a lot! I read now 2 pages on metaclasses and I'm beginning to really
feel I'm figuring it out... I'll read a bit more and once I start
implementation and if I have any problems I'll ask back...

To anyone else curious about how the issue can be solved: the keyword is
indeed "metclasses"

Thanks for the help!

On Tue, Sep 2, 2008 at 1:05 PM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
> On 2 sep, 10:33, "Abdallah El Guindy" <[EMAIL PROTECTED]>
> wrote:
> > Thank you very much for your reply. It seems that you understood my
> question
> > really well, but the answer is not as simple as I expected...
>
> ORMs are not a "simple" topic. Nor are advanced Python OO features.
>
> > I am trying to
> > implement something similar.
>
> You mean, some way to specify a 'schema' for an object using 'smart'
> properties ?
>
> > Could you explain a bit more (as I am no Python
> > Guru)?
>
> If you don't have a good enough knowledge of Python's object model
> (lookup rules, metaclasses, descriptor protocol etc), you'll have hard
> time understanding any explanation. And if you have this knowledge,
> you won't need my explanations anymore.
>
> IOW : first learn about the above topics (hint : all this is
> documented on python.org, and you'll find help and more infos on
> comp.lang.py).
>
> > Can you you point me to the part in the Django source that does that?
>
> django/db/models/base.py and django/db/models/fields/* should be a
> good start.
>
> HTH
> >
>

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



Determine if model item is subclassed

2008-09-02 Thread gauteh

Hello

Im trying to create a webpage that displays several types of posts on
the front page, they all inherit from a basic Item class (say
BasicItem). On the front page I query for BasicItem.objects.all()
[0:20] and I want to pass them on to my template and let my template
render each item based on the actual subclass it is, using custom
templatetags that render each item. There does not exist a BasicItem
without a subclass. The subitems will be something like NewsItem,
LinkItem, ImageItem and share attributes like author, date_posted,
category, tags and so on..

the template would be something like:

{% for item in items %}
{% ifequal item.subclass news %}
 {% rendernews item %}
 {% endif %}
 {% ifequal item.subclass link %}
  {% renderlink item %}
 {% endif %}
{% endfor %}

is there a different way to accomplish what im trying to do? or do i
need to check in my view function for which subclass that exists:
try:
n = items.newsitem
except DoesNotExist:
pass
try:
l = items.linkitem
except DoesNotExist:
   pass

and then mark the item somehow so that the template can read it?

- gaute

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



Re: formset issue

2008-09-02 Thread koenb

Something like this might work I think:

attachment_formset = BookingAttachmentFormSet(prefix = "attachments")
for form in attachment_formset.forms:
form.fields['attachment'].queryset =
Attachment.objects.filter(user=request.user)

Koen

On 2 sep, 13:05, patrickk <[EMAIL PROTECTED]> wrote:
> hmm, if the data won´t be received twice this might be a solution.
> do you have any idea about the syntax?
>
> attachment_formset = BookingAttachmentFormSet(prefix="attachments")
> for form in attachment_formset:
>     ??? how do I set initial_data here ???
>
> thanks,
> patrick
>
> On Sep 1, 3:39 pm, koenb <[EMAIL PROTECTED]> wrote:
>
> > Are you sure the data will be retrieved twice ? I thought those
> > queryset definitions were lazy, so they are only executed when the
> > widgets are rendered.
> > Hmm, I'll try that out some time to check.
>
> > Koen
>
> > On 1 sep, 14:18, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > that seems to be possible. on the other hand, it also seems to be a
> > > strange way to go: instantiating the formset (retrieving all data/
> > > querysets) and then changing the querysets? performance-wise, this is
> > > probably not a good solution. and I doubt that this is a good decision
> > > design-wise ...
>
> > > thanks,
> > > patrick
>
> > > On Sep 1, 1:51 pm, koenb <[EMAIL PROTECTED]> wrote:
>
> > > > I have not tried this, but can't you just in your view instantiate the
> > > > formset and then loop over the forms and set the queryset on your
> > > > field ?
>
> > > > Koen
>
> > > > On 1 sep, 09:24, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > found a solution: with using threadlocals, it´s possible to define a
> > > > > custom manager which only returns the data assigned to the currently
> > > > > logged-in user. since threadlocals has been considered a "hack"
> > > > > recently by one of the main django-developers (I think it was
> > > > > malcolm), this is probably not the best thing to do though.
>
> > > > > On Aug 31, 4:35 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > > sorry for being so annoying with this issue, but I´m asking this one
> > > > > > more time.
>
> > > > > > - with using inlineformset_factory, my problem is that limiting the
> > > > > > choices to the currently logged-in user seems impossible. I´ve just
> > > > > > tried to write a custom manger with "use_for_related_fields = True",
> > > > > > but it´s also not possible to limit the basic queryset to the 
> > > > > > current
> > > > > > user.
>
> > > > > > so - before going back to pure forms and re-writing the main part of
> > > > > > my application, I´m just asking this question for the last time ...
>
> > > > > > thanks,
> > > > > > patrick
>
> > > > > > On Aug 27, 9:04 am, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > > > anyone?
>
> > > > > > > On Aug 26, 12:19 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > scenario: users are uploading documents (e.g. images, files, 
> > > > > > > > ...).
> > > > > > > > these documents are saved in a model "Attachment" assigned to 
> > > > > > > > the
> > > > > > > > currently logged-in "User". now, every user has the possibility 
> > > > > > > > to
> > > > > > > > attach documents to a blog-entry. these attachments are saved 
> > > > > > > > in a
> > > > > > > > model "BlogEntryAttachment" assigned to a "BlogEntry".
> > > > > > > > the best way to achieve this is probably using formsets. when 
> > > > > > > > writing
> > > > > > > > a BlogEntry, the user has the option to attach his/her 
> > > > > > > > documents to
> > > > > > > > that BlogEntry. to achieve this, I have to limit the choices 
> > > > > > > > (of a
> > > > > > > > select-field) to the currenlty logged-in User.
>
> > > > > > > > questions & notes:
> > > > > > > > ### how can I limit the choices of a select-field using 
> > > > > > > > formsets?
> > > > > > > > ### I've tried inlineformset_factory, but there's no argument
> > > > > > > > "initial". besides that, I´m not sure how to use "initial" for
> > > > > > > > limiting a queryset ...
> > > > > > > > ### with using formset_factory on the other hand, I could use a
> > > > > > > > ModelChoiceField with 
> > > > > > > > queryset=Attachment.objects.filter(user=user),
> > > > > > > > but how do I get the "user" there?
> > > > > > > > ### Overriding __init__ within BlogEntryAttachmentForm and 
> > > > > > > > passing the
> > > > > > > > currently logged-in user seems possible, but then I also have to
> > > > > > > > override the BaseFormSets __init__ and _construct_form, which 
> > > > > > > > just
> > > > > > > > seems ugly and far too complicated.
>
> > > > > > > > MODELS:
>
> > > > > > > > class Attachment(models.Model):
>
> > > > > > > >     user = models.ForeignKey('auth.User')
> > > > > > > >     title = models.CharField('Title', max_length=100, 
> > > > > > > > blank=True,
> > > > > > > > null=True)
> > > > > > > >     filename = models.CharField('Filename', max_length=100,
> > > > > > > > blank=True, null=True)
> > > > > > > >     

Re: dumb question model-dictionary

2008-09-02 Thread bruno desthuilliers

On 2 sep, 10:18, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 2, 2008 at 2:30 AM, bruno desthuilliers
>
> <[EMAIL PROTECTED]> wrote:
> > More seriously, it took me 2 minutes playing with a model object in
> > the interactive shell to come up with what seems a working solution:
>
> Yeah, which is why I pointed out the easy wrapper function for it in
> my email above.

Yeps, but reading your answer first would have been like cheating,
isn't it ?-)




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



Re: formset issue

2008-09-02 Thread patrickk

hmm, if the data won´t be received twice this might be a solution.
do you have any idea about the syntax?

attachment_formset = BookingAttachmentFormSet(prefix="attachments")
for form in attachment_formset:
??? how do I set initial_data here ???

thanks,
patrick

On Sep 1, 3:39 pm, koenb <[EMAIL PROTECTED]> wrote:
> Are you sure the data will be retrieved twice ? I thought those
> queryset definitions were lazy, so they are only executed when the
> widgets are rendered.
> Hmm, I'll try that out some time to check.
>
> Koen
>
> On 1 sep, 14:18, patrickk <[EMAIL PROTECTED]> wrote:
>
> > that seems to be possible. on the other hand, it also seems to be a
> > strange way to go: instantiating the formset (retrieving all data/
> > querysets) and then changing the querysets? performance-wise, this is
> > probably not a good solution. and I doubt that this is a good decision
> > design-wise ...
>
> > thanks,
> > patrick
>
> > On Sep 1, 1:51 pm, koenb <[EMAIL PROTECTED]> wrote:
>
> > > I have not tried this, but can't you just in your view instantiate the
> > > formset and then loop over the forms and set the queryset on your
> > > field ?
>
> > > Koen
>
> > > On 1 sep, 09:24, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > found a solution: with using threadlocals, it´s possible to define a
> > > > custom manager which only returns the data assigned to the currently
> > > > logged-in user. since threadlocals has been considered a "hack"
> > > > recently by one of the main django-developers (I think it was
> > > > malcolm), this is probably not the best thing to do though.
>
> > > > On Aug 31, 4:35 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > sorry for being so annoying with this issue, but I´m asking this one
> > > > > more time.
>
> > > > > - with using inlineformset_factory, my problem is that limiting the
> > > > > choices to the currently logged-in user seems impossible. I´ve just
> > > > > tried to write a custom manger with "use_for_related_fields = True",
> > > > > but it´s also not possible to limit the basic queryset to the current
> > > > > user.
>
> > > > > so - before going back to pure forms and re-writing the main part of
> > > > > my application, I´m just asking this question for the last time ...
>
> > > > > thanks,
> > > > > patrick
>
> > > > > On Aug 27, 9:04 am, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > > anyone?
>
> > > > > > On Aug 26, 12:19 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > > > scenario: users are uploading documents (e.g. images, files, ...).
> > > > > > > these documents are saved in a model "Attachment" assigned to the
> > > > > > > currently logged-in "User". now, every user has the possibility to
> > > > > > > attach documents to a blog-entry. these attachments are saved in a
> > > > > > > model "BlogEntryAttachment" assigned to a "BlogEntry".
> > > > > > > the best way to achieve this is probably using formsets. when 
> > > > > > > writing
> > > > > > > a BlogEntry, the user has the option to attach his/her documents 
> > > > > > > to
> > > > > > > that BlogEntry. to achieve this, I have to limit the choices (of a
> > > > > > > select-field) to the currenlty logged-in User.
>
> > > > > > > questions & notes:
> > > > > > > ### how can I limit the choices of a select-field using formsets?
> > > > > > > ### I've tried inlineformset_factory, but there's no argument
> > > > > > > "initial". besides that, I´m not sure how to use "initial" for
> > > > > > > limiting a queryset ...
> > > > > > > ### with using formset_factory on the other hand, I could use a
> > > > > > > ModelChoiceField with 
> > > > > > > queryset=Attachment.objects.filter(user=user),
> > > > > > > but how do I get the "user" there?
> > > > > > > ### Overriding __init__ within BlogEntryAttachmentForm and 
> > > > > > > passing the
> > > > > > > currently logged-in user seems possible, but then I also have to
> > > > > > > override the BaseFormSets __init__ and _construct_form, which just
> > > > > > > seems ugly and far too complicated.
>
> > > > > > > MODELS:
>
> > > > > > > class Attachment(models.Model):
>
> > > > > > >     user = models.ForeignKey('auth.User')
> > > > > > >     title = models.CharField('Title', max_length=100, blank=True,
> > > > > > > null=True)
> > > > > > >     filename = models.CharField('Filename', max_length=100,
> > > > > > > blank=True, null=True)
> > > > > > >     path = models.CharField('Path', max_length=200, blank=True,
> > > > > > > null=True)
> > > > > > >     ...
>
> > > > > > > class BlogEntryAttachment(models.Model):
>
> > > > > > >     blogentry = models.ForeignKey(BlogEntry)
> > > > > > >     attachment = models.ForeignKey(Attachment)
> > > > > > >     
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more optio

Re: How is are Fields implemented?

2008-09-02 Thread bruno desthuilliers

On 2 sep, 10:33, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Thank you very much for your reply. It seems that you understood my question
> really well, but the answer is not as simple as I expected...

ORMs are not a "simple" topic. Nor are advanced Python OO features.

> I am trying to
> implement something similar.

You mean, some way to specify a 'schema' for an object using 'smart'
properties ?

> Could you explain a bit more (as I am no Python
> Guru)?

If you don't have a good enough knowledge of Python's object model
(lookup rules, metaclasses, descriptor protocol etc), you'll have hard
time understanding any explanation. And if you have this knowledge,
you won't need my explanations anymore.

IOW : first learn about the above topics (hint : all this is
documented on python.org, and you'll find help and more infos on
comp.lang.py).

> Can you you point me to the part in the Django source that does that?

django/db/models/base.py and django/db/models/fields/* should be a
good start.

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



URLs Syntax Error

2008-09-02 Thread djandrow

Hi, I have the following URLs.py

from django.conf.urls.defaults import *
from akonline.views import current_datetime
from django.views.generic import date_based
from akonline.blog.models import Category, Entry

archive_info = {
"queryset" : Entry.objects.all(),
"date_field" : "entry_date"
}

urlpatterns = patterns('',

(r'^time/$', current_datetime),
(r'^blog/$', 'akonline.blog.views.get_entries'),
(r'^test/$', 'akonline.blog.views.blog'),
(r'^blog/(?P\w+)/$',
'akonline.blog.views.category_entry'),

 # Date based URLS:

#LINE 20 Below:

 (r'^archive/$', date_based.archive_index,
archive_info {'template_name': 'blog/archive.html'}),
 (r'^archive/(?Pd{4})/?$',
date_based.archive_year, archive_info {'template_name': 'blog/
archive.html'}),

# Uncomment this for admin:
# (r'^admin/', include('django.contrib.admin.urls')),
)

and on line 20 I get the following error:

Request Method: GET
Request URL: http://www.andrewkenyononline.net/test/
Django Version: 1.0-beta_2-SVN-8849
Python Version: 2.4.4
Installed Applications:
['akonline.blog']
Installed Middleware:
()


Traceback:
File "/home/django/django_src/django/core/handlers/base.py" in
get_response
  76. callback, callback_args, callback_kwargs =
resolver.resolve(
File "/home/django/django_src/django/core/urlresolvers.py" in resolve
  178. for pattern in self.urlconf_module.urlpatterns:
File "/home/django/django_src/django/core/urlresolvers.py" in
_get_urlconf_module
  197. self._urlconf_module =
__import__(self.urlconf_name, {}, {}, [''])

Exception Type: SyntaxError at /test/
Exception Value: invalid syntax (urls.py, line 20)

This is my first attempt at using data based views so the same error
probably occurs on line 21 as well. I would appreciate any help.

Regards,

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



Re: MySQL timediff and datetime.timedelta

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 03:16 -0700, Jens Grivolla wrote:
> Hi,
> 
> I am getting weird results using django.db to do a "select
> timediff(a,b)..." query from MySQL.  The result is a datetime.datetime
> object instead of a datetime.timedelta.  When using MySQLdb directly,
> it returns the expected timedelta object. 

Are you really getting a datetime.datetime and not a datetime.time? I
would have expected you might get the latter, since we map any TIME type
of column to a datetime.time. I can't see how you would be getting a
datetime, though.

Regards,
Malcolm



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



MySQL timediff and datetime.timedelta

2008-09-02 Thread Jens Grivolla

Hi,

I am getting weird results using django.db to do a "select
timediff(a,b)..." query from MySQL.  The result is a datetime.datetime
object instead of a datetime.timedelta.  When using MySQLdb directly,
it returns the expected timedelta object.  The code is exactly
identical in both cases other than using django.db.connection instead
of MySQLdb.connect(...)

I'm using default packages on Ubuntu 8.04 (django 0.96.1-2ubuntu2,
mysqldb 1.2.2-5ubuntu1, mysql 5.0.51a-3ubuntu5.1).

Any clues?

Thanks,
Jens

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



doctest for multi-threaded apps

2008-09-02 Thread omat

Is it possible to test multi-threaded applications with doctests?

I use the Timer module, which is inherited from Thread, to trigger a
function after certain time, for example 1 second.

When I run the test, and let the main thread sleep with time.sleep(),
to give time for the triggered function to be called, I receive a:

Exception in thread Thread-2:
... traceback ...
OperationalError: no such table: game_question


Does this mean the db tables are created only for the main thread and
other threads cannot access the temporary db?


Thanks,
oMat

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



  1   2   >