Re: class in models.py 'not defined' exception

2008-04-28 Thread Karen Tracey
On Tue, Apr 29, 2008 at 1:31 AM, skunkwerk <[EMAIL PROTECTED]> wrote:

>
> thanks karen,
>   i think my views.py file is the source of the error, as it tries to
> import from winebago.models like so:
>
> from winebago.models import Models
>

> (Models is defined after AuthPermission in models.py, and there are 3
> other tables defined before AuthPermission in models.py - none of
> which raise an error).  As far as I can tell, AuthPermission was
> created by the authentication module; i've commented out everything
> else in my views.py file after the 'from winebago.models import
> Models', so it's not like I'm trying to call AuthPermission without it
> being defined.  these are the only lines in views.py:
>

Wait, why are you including in your models.py file definitions for classes
created by Django-provided components?  You don't need to do that.  If you
need to use an auth model, import it from django.contrib.auth.models or
wherever it is defined.  You should not duplicate the model definitions for
Django-provided models.  I'd get rid of everything in your models file that
is not related to one of your own application's models, and move on from
there.

Karen


>
> from django.shortcuts import render_to_response
> from django.http import HttpResponseRedirect
> from django.core.urlresolvers import reverse
> from winebago.models import Models
>
> here is my urls.py file (i commented everything out to figure out
> where the error was from):
>
> from django.conf.urls.defaults import *
> from winebago.views import homepage
> urlpatterns = patterns('',
> )
>
> am i doing something wrong?
>
> On Apr 28, 9:11 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Mon, Apr 28, 2008 at 11:54 PM, skunkwerk <[EMAIL PROTECTED]> wrote:
> >
> > > I've been struggling with this error for the past hour.
> >
> > > Error while importing URLconf 'winebago.urls': name 'AuthPermission'
> > > is not defined
> > > Exception Location: /usr/lib/python2.5/site-packages/django/core/
> > > urlresolvers.py in _get_urlconf_module, line 255
> >
> > > my models.py was generated by: ./manage.py inspectdb > models.py
> >
> > > the relevant lines from models.py:
> > > class AuthPermission(models.Model):
> > >id = models.IntegerField(primary_key=True)
> > >name = models.CharField(max_length=150)
> > >content_type = models.ForeignKey(DjangoContentType)
> > >codename = models.CharField(unique=True, max_length=300)
> > >class Meta:
> > >db_table = u'auth_permission'
> >
> > > i can't figure out why this is happening, as i didn't change anything
> > > to do with the models.
> >
> > The problem is in your winebago urls.py file.  You are apparently
> referring
> > to AuthPermission without having first imported it (via something like
> from
> > winebago.models import AuthPermission).  Without an import Python
> doesn't
> > know where to find the definition for something that has not already
> been
> > defined in the file it is processing.
> >
> > Karen
> >
>

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



Re: class in models.py 'not defined' exception

2008-04-28 Thread skunkwerk

thanks karen,
   i think my views.py file is the source of the error, as it tries to
import from winebago.models like so:

from winebago.models import Models

(Models is defined after AuthPermission in models.py, and there are 3
other tables defined before AuthPermission in models.py - none of
which raise an error).  As far as I can tell, AuthPermission was
created by the authentication module; i've commented out everything
else in my views.py file after the 'from winebago.models import
Models', so it's not like I'm trying to call AuthPermission without it
being defined.  these are the only lines in views.py:

from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from winebago.models import Models

here is my urls.py file (i commented everything out to figure out
where the error was from):

from django.conf.urls.defaults import *
from winebago.views import homepage
urlpatterns = patterns('',
)

am i doing something wrong?

On Apr 28, 9:11 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Apr 28, 2008 at 11:54 PM, skunkwerk <[EMAIL PROTECTED]> wrote:
>
> > I've been struggling with this error for the past hour.
>
> > Error while importing URLconf 'winebago.urls': name 'AuthPermission'
> > is not defined
> > Exception Location: /usr/lib/python2.5/site-packages/django/core/
> > urlresolvers.py in _get_urlconf_module, line 255
>
> > my models.py was generated by: ./manage.py inspectdb > models.py
>
> > the relevant lines from models.py:
> > class AuthPermission(models.Model):
> >    id = models.IntegerField(primary_key=True)
> >    name = models.CharField(max_length=150)
> >    content_type = models.ForeignKey(DjangoContentType)
> >    codename = models.CharField(unique=True, max_length=300)
> >    class Meta:
> >        db_table = u'auth_permission'
>
> > i can't figure out why this is happening, as i didn't change anything
> > to do with the models.
>
> The problem is in your winebago urls.py file.  You are apparently referring
> to AuthPermission without having first imported it (via something like from
> winebago.models import AuthPermission).  Without an import Python doesn't
> know where to find the definition for something that has not already been
> defined in the file it is processing.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToMany relationshops between models?

2008-04-28 Thread [EMAIL PROTECTED]

Yes django.contrib.comments is scheduled to be rewritten as a part of
the Google Summer of Code.

On Apr 29, 12:01 am, Mike Chambers <[EMAIL PROTECTED]> wrote:
> Thanks.
>
> Ill take a look at that, as well as some of the other comments framework.
>
> I had looked at the django  comments, but it looked like it wasnt really
> supported, and might change soon.
>
> mike chambers
>
> [EMAIL PROTECTED] wrote:
> > For something like this the best way to do this is a generic foreign
> > key, here is an 
> > example:http://www.djangoproject.com/documentation/models/generic_relations/
> > .  For comments though you should probably check out,
> > django.contrib.comments, or one of the other open source comment
> > packages(such as threadedcomments).
>
> > On Apr 28, 11:40 pm, Mike Chambers <[EMAIL PROTECTED]> wrote:
> >> I am writing my first django app. I have Items, which can have multiple
> >> comments associated with them.
>
> >> Normally, I could express this in my model as:
>
> >> ---
> >> class Comment(models.Model):
> >>         comment = models.TextField(core=True)
> >>         item = models.ForeignKey(Item)
>
> >> class Item(models.Model):
> >>         name = models.CharField(core=True, max_length=255, unique=True)
> >> ---
>
> >> However, I am trying to learn to split my project up into individual
> >> applications, and have thus put the comment functionality in its own
> >> app. I dont mind if the Item app knows about the Comment app, but I
> >> don't want to Comment app to reference the Item app (so I can use
> >> comments with other apps / types in the future).
>
> >> So, is there anyway to express a OneToMany relationship from the Item?
> >> Something like:
>
> >> class Comment(models.Model):
> >>         comment = models.TextField(core=True)
>
> >> class Item(models.Model):
> >>         name = models.CharField(core=True, max_length=255, unique=True)
> >>         comments = models.OneToMany(Comment)
>
> >> That would accomplish the same as above, but would allow me to keep my
> >> Comment model from having to know what type of objects it is being
> >> associated with.
>
> >> I apologize if this has an obvious answer. Again, I am new to django,
> >> and trying to work my way through the best way to use the framework
> >> (which I love, btw).
>
> >> mike chambers
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Session/Varibale and HttpResponseRedirect help please

2008-04-28 Thread Brandon Taylor

Hello everyone,

I'm doing a redirect after a form to a "thank you" page, which I would
like to personalize with some of the data from the form. I've tried
setting a session as such:

### views.py code

if form.is_valid():
first_name = form.cleaned_data['first_name']
request.session['first_name'] = first_name

return HttpResponseRedirect('training/thanks/')


But, when I try to output the value in the "thanks" template, as such:

def thanks(request):
first_name = request.session.get('first_name')
return render_to_response('thanks.html', 'first_name' :
first_name)


I get nothing. I've checked to make sure that the sessions middleware,
and the sessions app are included in my settings.py file. What am I
doing wrong? Help appreciated!

Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: data field error running mysql 5.0.45 django 0.96.1

2008-04-28 Thread Karen Tracey
2008/4/28 unixdude_from_mars <[EMAIL PROTECTED]>:

>
> I am attempting to query my database for a DateField.  I use the
> following lines to set the qset in my view code.
>
> query = request.GET.get('q','')
> if query:
>   (
>  Q(end__icontains=query) |
>  Q(maintenance_contractor__name__icontains=query) |
>  Q(purchase_order__icontains=query)
>   )
>
>   results = Maintenance_item.objects.filter(qset).distinct()
> else:
>   results=[]
>
> This code fails and the gives the following dump when I attempt to
> query on date,
> P.S. even an input with an exact match will fail with the same error.
> note the example is a partial match on year.
>
> thanks for any help.  --
>
> james
>
>
> Warning at /search/
> Incorrect date value: '%'2007'%' for column 'end' at row 1
> Request Method: GET
> Request URL:http://localhost:8000/search/
> Exception Type: Warning
> Exception Value:Incorrect date value: '%'2007'%' for column 'end'
> at
> row 1
> Exception Location: /opt/csw/lib/python/warnings.py in warn_explicit,
> line 102
> Template error
>

> In template /export/home/jhartley/djcode/mysite/templates/search.html,
> error at line 18
> Caught an exception while rendering: Incorrect date value: '%'2007'%'
> for column 'end' at row 1


First, it looks like there is an extra set of quotes around 2007, as though
the 'q' value you retrieve from the GET parameters is enclosed in quotes.  I
wouldn't expect this query to work without first getting rid of the extra
quotes.

The second problem is that Django's icontains comparison maps to MySQL's
LIKE comparison.  LIKE is a string comparison function, but a DateField is
not a string datatype.  So you are comparing mismatched types, and this
generates a warning from MySQL.  You can see this with just the mysql
command, no Django involved (on my own DB):

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5055
Server version: 5.0.45-Debian_1ubuntu3.3-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select count(*) from Puzzles where Date like '%2008%';
+--+
| count(*) |
+--+
|  740 |
+--+
1 row in set, 1 warning (0.03 sec)

mysql> show warnings;
+-+--+---+
| Level   | Code | Message
|
+-+--+---+
| Warning | 1292 | Incorrect date value: '%2008%' for column 'Date' at row 1
|
+-+--+---+
1 row in set (0.01 sec)

So, mysql was able to compute the right answer, but did issue a warning
about the type mismatch.  Under Django that warning causes an error, since,
as I understand it, some MySQL warnings are really serious error conditions,
and it is impossible for Django to distinguish the non-serious from the
serious ones.  Therefore all warnings are converted to errors.


> This code DOES work correctly with mysql 5.0.27 and yields dataField
> data properly
>

I'd guess, then, that the warning was added to MySQL sometime between 5.0.27
and 5.0.45.  I don't have an old level to check myself.


> Has anyone run across this and if so is there a patch.
>

A syntax to get MySQL to do this kind of comparison without a warning is:

mysql> select count(*) from Puzzles where cast(Date as char) like '%2008%';
+--+
| count(*) |
+--+
|  740 |
+--+
1 row in set (0.00 sec)

However, I don't know of any way to make Django generate that kind of SQL.
Based on the other fields you are including in your filter, it looks like
you want to have a single (string) query parameter and use it to match
against different fields -- some string, at least one not.  I don't know if
there is any way to do that. But it is late, so perhaps I am just missing
something...maybe someone else will have a good idea.

Karen

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



Re: OneToMany relationshops between models?

2008-04-28 Thread Mike Chambers

Thanks.

Ill take a look at that, as well as some of the other comments framework.

I had looked at the django  comments, but it looked like it wasnt really 
supported, and might change soon.

mike chambers


[EMAIL PROTECTED] wrote:
> For something like this the best way to do this is a generic foreign
> key, here is an example: 
> http://www.djangoproject.com/documentation/models/generic_relations/
> .  For comments though you should probably check out,
> django.contrib.comments, or one of the other open source comment
> packages(such as threadedcomments).
> 
> On Apr 28, 11:40 pm, Mike Chambers <[EMAIL PROTECTED]> wrote:
>> I am writing my first django app. I have Items, which can have multiple
>> comments associated with them.
>>
>> Normally, I could express this in my model as:
>>
>> ---
>> class Comment(models.Model):
>> comment = models.TextField(core=True)
>> item = models.ForeignKey(Item)
>>
>> class Item(models.Model):
>> name = models.CharField(core=True, max_length=255, unique=True)
>> ---
>>
>> However, I am trying to learn to split my project up into individual
>> applications, and have thus put the comment functionality in its own
>> app. I dont mind if the Item app knows about the Comment app, but I
>> don't want to Comment app to reference the Item app (so I can use
>> comments with other apps / types in the future).
>>
>> So, is there anyway to express a OneToMany relationship from the Item?
>> Something like:
>>
>> class Comment(models.Model):
>> comment = models.TextField(core=True)
>>
>> class Item(models.Model):
>> name = models.CharField(core=True, max_length=255, unique=True)
>> comments = models.OneToMany(Comment)
>>
>> That would accomplish the same as above, but would allow me to keep my
>> Comment model from having to know what type of objects it is being
>> associated with.
>>
>> I apologize if this has an obvious answer. Again, I am new to django,
>> and trying to work my way through the best way to use the framework
>> (which I love, btw).
>>
>> mike chambers
> > 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: OneToMany relationshops between models?

2008-04-28 Thread [EMAIL PROTECTED]

For something like this the best way to do this is a generic foreign
key, here is an example: 
http://www.djangoproject.com/documentation/models/generic_relations/
.  For comments though you should probably check out,
django.contrib.comments, or one of the other open source comment
packages(such as threadedcomments).

On Apr 28, 11:40 pm, Mike Chambers <[EMAIL PROTECTED]> wrote:
> I am writing my first django app. I have Items, which can have multiple
> comments associated with them.
>
> Normally, I could express this in my model as:
>
> ---
> class Comment(models.Model):
>         comment = models.TextField(core=True)
>         item = models.ForeignKey(Item)
>
> class Item(models.Model):
>         name = models.CharField(core=True, max_length=255, unique=True)
> ---
>
> However, I am trying to learn to split my project up into individual
> applications, and have thus put the comment functionality in its own
> app. I dont mind if the Item app knows about the Comment app, but I
> don't want to Comment app to reference the Item app (so I can use
> comments with other apps / types in the future).
>
> So, is there anyway to express a OneToMany relationship from the Item?
> Something like:
>
> class Comment(models.Model):
>         comment = models.TextField(core=True)
>
> class Item(models.Model):
>         name = models.CharField(core=True, max_length=255, unique=True)
>         comments = models.OneToMany(Comment)
>
> That would accomplish the same as above, but would allow me to keep my
> Comment model from having to know what type of objects it is being
> associated with.
>
> I apologize if this has an obvious answer. Again, I am new to django,
> and trying to work my way through the best way to use the framework
> (which I love, btw).
>
> mike chambers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



OneToMany relationshops between models?

2008-04-28 Thread Mike Chambers

I am writing my first django app. I have Items, which can have multiple 
comments associated with them.

Normally, I could express this in my model as:

---
class Comment(models.Model):
comment = models.TextField(core=True)
item = models.ForeignKey(Item)

class Item(models.Model):
name = models.CharField(core=True, max_length=255, unique=True)
---

However, I am trying to learn to split my project up into individual 
applications, and have thus put the comment functionality in its own 
app. I dont mind if the Item app knows about the Comment app, but I 
don't want to Comment app to reference the Item app (so I can use 
comments with other apps / types in the future).

So, is there anyway to express a OneToMany relationship from the Item? 
Something like:

class Comment(models.Model):
comment = models.TextField(core=True)


class Item(models.Model):
name = models.CharField(core=True, max_length=255, unique=True)
comments = models.OneToMany(Comment)

That would accomplish the same as above, but would allow me to keep my 
Comment model from having to know what type of objects it is being 
associated with.

I apologize if this has an obvious answer. Again, I am new to django, 
and trying to work my way through the best way to use the framework 
(which I love, btw).

mike chambers

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Template Tags Inside 'ifequals'

2008-04-28 Thread Szaijan

Perfect.  Thanks guys.  While I don't really agree with the philosophy
behind purposely limiting the template language, as a rule I prefer to
keep as much in the view as possible, so this solution appeals to me.

Bottom line, if I weren't using mostly Javascript based, Ajax style
updates, I would likely use a more powerful templating language.  As
it is, Django's templating  meets most of my needs.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Render raw image

2008-04-28 Thread Brian

Have you considered creating a separate view for that particular
image? You'd have a view designed to grab that image and return it
with the proper MIME type. Then you could, in your Welcome method,
return a dynamically generated path to that URL using the reverse()
method, which you'd use in your  tag in your template.

On Apr 28, 2:54 pm, hareesh <[EMAIL PROTECTED]> wrote:
> (I'm a django n00b).
>
> Through a database, I get the raw contents of an image and the image's
> mimetype:
>
> def Welcome(request):
>   (mime, blob) = d.GetMedia()
>   ...
>   return shortcuts.render_to_response('welcome.html', { 'msg'  :
> 'Welcome!', 'logo' : blob }) # Line 3
>
> Now clearly, this (Line 3) doesn't work as I intend it to. So what is
> the best way of showing the raw image? Must I write it to my "static
> files" directory and then pass the full path of the newly written
> image, to the context dict in render_to_response?
>
> 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: class in models.py 'not defined' exception

2008-04-28 Thread Karen Tracey
On Mon, Apr 28, 2008 at 11:54 PM, skunkwerk <[EMAIL PROTECTED]> wrote:

>
> I've been struggling with this error for the past hour.
>
> Error while importing URLconf 'winebago.urls': name 'AuthPermission'
> is not defined
> Exception Location: /usr/lib/python2.5/site-packages/django/core/
> urlresolvers.py in _get_urlconf_module, line 255
>
> my models.py was generated by: ./manage.py inspectdb > models.py
>
> the relevant lines from models.py:
> class AuthPermission(models.Model):
>id = models.IntegerField(primary_key=True)
>name = models.CharField(max_length=150)
>content_type = models.ForeignKey(DjangoContentType)
>codename = models.CharField(unique=True, max_length=300)
>class Meta:
>db_table = u'auth_permission'
>
> i can't figure out why this is happening, as i didn't change anything
> to do with the models.
>

The problem is in your winebago urls.py file.  You are apparently referring
to AuthPermission without having first imported it (via something like from
winebago.models import AuthPermission).  Without an import Python doesn't
know where to find the definition for something that has not already been
defined in the file it is processing.

Karen

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



class in models.py 'not defined' exception

2008-04-28 Thread skunkwerk

I've been struggling with this error for the past hour.

Error while importing URLconf 'winebago.urls': name 'AuthPermission'
is not defined
Exception Location: /usr/lib/python2.5/site-packages/django/core/
urlresolvers.py in _get_urlconf_module, line 255

my models.py was generated by: ./manage.py inspectdb > models.py

the relevant lines from models.py:
class AuthPermission(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=150)
content_type = models.ForeignKey(DjangoContentType)
codename = models.CharField(unique=True, max_length=300)
class Meta:
db_table = u'auth_permission'

i can't figure out why this is happening, as i didn't change anything
to do with the models.

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



Re: passing form to base template

2008-04-28 Thread Ronny Haryanto

On Tue, Apr 29, 2008 at 9:33 AM, skunkwerk <[EMAIL PROTECTED]> wrote:
>  I've got two forms included in my base template, from which a few
>  others inherit.  Currently I'm passing a newly-constructed form to
>  each of the inherited templates in the functions using
>  render_to_response, like so:
>
>  return render_to_response('contact.html', {'form': form,  'suggform':
>  suggform,  'searchform':searchform })
>
>  it's getting tedious though... is there some way I can pass the forms
>  to only the base template, and have all the other inherited templates
>  get the forms too?  the default forms are all static - no dynamic
>  values.

Would a custom context processor work for you?
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext

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



passing form to base template

2008-04-28 Thread skunkwerk

I've got two forms included in my base template, from which a few
others inherit.  Currently I'm passing a newly-constructed form to
each of the inherited templates in the functions using
render_to_response, like so:

return render_to_response('contact.html', {'form': form,  'suggform':
suggform,  'searchform':searchform })

it's getting tedious though... is there some way I can pass the forms
to only the base template, and have all the other inherited templates
get the forms too?  the default forms are all static - no dynamic
values.

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: get_or_create and foreign keys

2008-04-28 Thread davenaff

This might be a syntax problem. This is the syntax I use:

object, created = Entity.objects.get_or_create(id=12)

On Apr 28, 12:12 pm, Thierry <[EMAIL PROTECTED]> wrote:
> The get or create syntax does not appear to support the following
> syntax:
>
> object, created = get_or_create(entity_id = 12)
>
> it fails on the _id part.
> is there anyway to give it numbers instead of objects?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread davenaff

Awesome work. 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: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread Craig Ogg

w00t!

Not sure where to point this out, but anyone using the full text
search implementation from Mercurytide[1] will get the following
error:

   django/db/models/query.py
   line c = klass(model=self.model, query=self.query.clone())
   "__init__() got an unexpected keyword argument 'query'"

The sample classes they define are subclassing without handling *args
and *kwargs.  This is easy to resolve by adding them:

  class SearchManager(models.Manager):
  def __init__(self, index_column, *args, **kwargs):
  super(SearchManager, self).__init__(*args, **kwargs)
  self._index_column = index_column

Craig
[1] http://www.mercurytide.co.uk/whitepapers/django-full-text-search/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Template Tags Inside 'ifequals'

2008-04-28 Thread Darryl Ross

Darryl Ross wrote:

Szaijan wrote:

Is there a way to access the URL values assigned to the view names
within a view?  Perhaps something less inelegant than importing
urls.py and searching for the view name in the tuple?  Otherwise I've
traded hardcoding URLs into one template for hard coding them into 5+
views.


Hmm, I should probably learn to read a bit closer. Sorry, I missed 
"within a view,".


As Malcolm said look up the reverse() function.

Cheers
-Darryl



signature.asc
Description: OpenPGP digital signature


Re: Template Tags Inside 'ifequals'

2008-04-28 Thread Malcolm Tredinnick


On Mon, 2008-04-28 at 17:49 -0700, Szaijan wrote:
> Thanks Malcolm.
> 
> Is there a way to access the URL values assigned to the view names
> within a view?  Perhaps something less inelegant than importing
> urls.py and searching for the view name in the tuple?  Otherwise I've
> traded hardcoding URLs into one template for hard coding them into 5+
> views.

Import the reverse() function from django.core.urlresolvers and use that
like the "url" template tag (the "url" template tag is implemented using
reverse()). Look at the arguments to reverse() in the code to make sure
you get it right -- it's important to pass it keyword arguments because
you have to omit the second position argument.

Regards,
Malcolm

-- 
Save the whales. Collect the whole set. 
http://www.pointy-stick.com/blog/


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



Re: Overriding model __init__() method

2008-04-28 Thread Malcolm Tredinnick


On Mon, 2008-04-28 at 17:20 -0700, Nathaniel Whiteinge wrote:
> I'm using the __init__() method in a few models to save state for
> later use in save(), e.g.::
> 
> class MyModel(models.Model):
> ...
> def __init__(self, *args, **kwargs):
> super(MyModel, self).__init__(*args, **kwargs)
> self.old_value = self.value
> def save(self):
> if self.old_value != self.value:
> ...
> super(MyModel, self).save()
> 
> But that functionality seems to have broken in the last week. It
> appears that __init__() isn't be called (as often?) as it used to. I'm
> on the GIS branch and it seems to have broken on r7482 (qs-rf merge).

Can you open a ticket for this please? I need to think about it a bit
because it might be fiddly to fix.

The underlying issue is that object initialisation has changed and I
didn't think of this sort of situation (overriding __init__ was fragile
in the distant past; not so much in recent times). What's now going on
is that there's a "fast" creation method of models that is used when
initialising them from a sequence of arguments -- primarily for database
creation. That's the from_sequence() method on the Model class. Because
that's a class constructor, it doesn't also call __init__() -- it
replaces __init__.

So, like I said, I should think about some alternative approaches here.
We kind of need the fast path for code robustness and speed (it can
throw away a bunch of error checking in that path because it's not
intended for general public use), but I don't want to break normal
Python practices either. Open a ticket and I'll put some effort in.

Regards,
Malcolm

-- 
Honk if you love peace and quiet. 
http://www.pointy-stick.com/blog/


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



Re: Template Tags Inside 'ifequals'

2008-04-28 Thread Darryl Ross

Szaijan wrote:

Is there a way to access the URL values assigned to the view names
within a view?  Perhaps something less inelegant than importing
urls.py and searching for the view name in the tuple?  Otherwise I've
traded hardcoding URLs into one template for hard coding them into 5+
views.


Does http://www.djangoproject.com/documentation/templates/#url not do 
what you want?


eg:

# urls.py
 url(r'^products/(?P\d+)', 'views.show_product', name='product_info'),


# template
{% for product in products %}

Details
{% endfor %}


Cheers
-Darryl




signature.asc
Description: OpenPGP digital signature


Re: Template Tags Inside 'ifequals'

2008-04-28 Thread Szaijan

Thanks Malcolm.

Is there a way to access the URL values assigned to the view names
within a view?  Perhaps something less inelegant than importing
urls.py and searching for the view name in the tuple?  Otherwise I've
traded hardcoding URLs into one template for hard coding them into 5+
views.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Registration Error (Does not return from SMTP call)

2008-04-28 Thread Szaijan

Just as an update, I was told that due to a security change at GMail,
libgmail is not currently functional, which certainly matches with my
complete inability to get it functioning as an SMTP sever for my
django-registration install.

Returning to local SMTP, I finally got it functioning on Debian Etch
by installing and configuring postfix and sasl2, accomplished thanks
to the excellent instructions found here:

http://howtoforge.com/perfect_setup_debian_etch_p5

I am still unable to get this working on my OS X 10.5 system.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Processing saves()

2008-04-28 Thread Darryl Ross

Lee Hinde wrote:

After the line item is saved, I want to call the Work Order to have it
update a Total Due column. Assuming I have the code in the Work Order
model to get all the related line items and sum the extended price,
what I would do is call the Work Order save() method from the Line
Item save() methd, after calling the super(save).


Yes, I do this in almost exactly the same situation.


That is:

class LineItems(models.Model):
item = models.CharField(max_length=100)
wo = models.ForeignKey(WorkOrder)

def save(self):
doLocalMath()
super(LineItems, self).save()
WorkOrder.save()


This can be written as:

class LineItems(models.Model):
item = models.CharField(max_length=100)

wo = models.ForeignKey(WorkOrder)

qty = models.IntegerField(default=1)
price = models.DecimalField(max_digits=12, decimal_places=2)

ext_price = models.DecimalField(blank=True, max_digits=12, 
decimal_places=2)


def save(self):
self.ext_price = self.qty * float(self.price)
super(LineItems, self).save()
self.wo.save()



And, sort of related,  I need to call custom SQL to get the sum of
related records, correct?


No, you can do it using the ORM:

class WorkOrder(models.Model):
total = models.DecimalField(max_digits=12, decimal_places=2)

def save(self):
self.total = sum([i.ext_price for i in self.lineitems_set.all()])
super(WorkOrder, self).save()



HTH
-Darryl




signature.asc
Description: OpenPGP digital signature


data field error running mysql 5.0.45 django 0.96.1

2008-04-28 Thread unixdude_from_mars

I am attempting to query my database for a DateField.  I use the
following lines to set the qset in my view code.

query = request.GET.get('q','')
if query:
   (
  Q(end__icontains=query) |
  Q(maintenance_contractor__name__icontains=query) |
  Q(purchase_order__icontains=query)
   )

   results = Maintenance_item.objects.filter(qset).distinct()
else:
   results=[]

This code fails and the gives the following dump when I attempt to
query on date,
P.S. even an input with an exact match will fail with the same error.
note the example is a partial match on year.

thanks for any help.  --

james


Warning at /search/
Incorrect date value: '%'2007'%' for column 'end' at row 1
Request Method: GET
Request URL:http://localhost:8000/search/
Exception Type: Warning
Exception Value:Incorrect date value: '%'2007'%' for column 'end' at
row 1
Exception Location: /opt/csw/lib/python/warnings.py in warn_explicit,
line 102
Template error

In template /export/home/jhartley/djcode/mysite/templates/search.html,
error at line 18
Caught an exception while rendering: Incorrect date value: '%'2007'%'
for column 'end' at row 1
8   Search
9   
10  Search: 
11  
12  
13  
14
15  {% if query %}
16  Results for "{{ query|escape }}":
17
18  {% if results %}
19  
20  {% for maintenance_item in results %}
21  {{ maintenance_item }}
22  {% endfor %}
23  
24  {% else %}
25  No Maintenance Items Found
26  {% endif %}
27  {% endif %}
28  
Traceback (innermost last)
Switch to copy-and-paste view

* /opt/csw/lib/python/site-packages/django/template/__init__.py in
render_node
   716.
   717. def render_node(self, node, context):
   718. return(node.render(context))
   719.
   720. class DebugNodeList(NodeList):
   721. def render_node(self, node, context):
   722. try:
   723. result = node.render(context) ...
   724. except TemplateSyntaxError, e:
   725. if not hasattr(e, 'source'):
   726. e.source = node.source
   727. raise
   728. except Exception, e:
   729. from sys import exc_info
  ▶ Local vars
  Variable  Value
  context
  Error in formatting:Incorrect date value: '%'2007'%' for column
'end' at row 1
  e
  Warning("Incorrect date value: '%'2007'%' for column 'end' at
row 1",)
  exc_info
  
  node
  
  self
  [Results for "'>, ,  '>, , ]
  wrapped
  TemplateSyntaxError("Caught an exception while rendering:
Incorrect date value: '%'2007'%' for column 'end' at row 1",)
* /opt/csw/lib/python/site-packages/django/template/defaulttags.py
in render
   201. def render(self, context):
   202. if self.link_type == IfNode.LinkTypes.or_:
   203. for ifnot, bool_expr in self.bool_exprs:
   204. try:
   205. value = bool_expr.resolve(context, True)
   206. except VariableDoesNotExist:
   207. value = None
   208. if (value and not ifnot) or (ifnot and not value): ...
   209. return self.nodelist_true.render(context)
   210. return self.nodelist_false.render(context)
   211. else:
   212. for ifnot, bool_expr in self.bool_exprs:
   213. try:
   214. value = bool_expr.resolve(context, True)
  ▶ Local vars
  Variable  Value
  bool_expr
  
  context
  Error in formatting:Incorrect date value: '%'2007'%' for column
'end' at row 1
  ifnot
  False
  self
  
  value
  Error in formatting:Incorrect date value: '%'2007'%' for column
'end' at row 1
* /opt/csw/lib/python/site-packages/django/db/models/query.py in
__len__
98. # PYTHON MAGIC METHODS #
99. 
   100.
   101. def __repr__(self):
   102. return repr(self._get_data())
   103.
   104. def __len__(self):
   105. return len(self._get_data()) ...
   106.
   107. def __iter__(self):
   108. return iter(self._get_data())
   109.
   110. def __getitem__(self, k):
   111. "Retrieve an item or slice from the set of results."
  ▶ Local vars
  Variable  Value
  self
  Error in formatting:Incorrect date value: '%'2007'%' for column
'end' at row 1
* /opt/csw/lib/python/site-packages/django/db/models/query.py in
_get_data
   463. if (self._order_by is not None and len(self._order_by) >
0) and \
   464. (combined._order_by is None or len(combined._order_by) ==
0):
   465. combined._order_by = self._order_by
   466. return combined
   467.
   468. def _get_data(self):
   469. if self._result_cache is None:
   470. self._result_cache = list(self.iterator()) ...
   471. return self._result_cache
   472.
   473. def _get_sql_clause(self):
   474. opts = self.model._meta
   475.
   476. # Construct the fundamental parts of the query: SELECT X
FROM Y WHERE Z.
  ▶ Local vars
  Variable  Value
  self
  

Django Registration URLs

2008-04-28 Thread Szaijan

I am using django_registration as part of my Django web app,
visionary.  The 'registration' directory is in the same base django
directory as 'visionary'.  I've imported 'registration/urls.py' into
my 'visionary/urls.py' via the line:

(r'^visionary/accounts/', include('registration.urls')),

The base urls function properly, i.e. /visionary/accounts/register
goes where it is supposed to, but when resulting URLs are called, they
all get called as /accounts/register/complete instead of /visionary/
accounts/register/complete.

Any ideas on how to fix this?  Am I supposed to have installed the
'registration' directory directly under the 'visionary' directory?  I
do have a soft link from inside 'visionary' to '../registration'.

Thanks for any insight.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Login issue

2008-04-28 Thread Darryl Ross

Hi Bret,

Can't see that anyone else has responded to this.

Bret W wrote:

There are many times when I can enter a username and password, click
the "login" button, and get the username/password don't match error.

The error page (/accounts/login, using example template from docs)
automatically fills in the username and password fields, and I can
just hit "login" again and I'm successfully logged in.  This means my
credentials were posted correctly.


Try reading up on the set_test_cookie() function at 
http://www.djangoproject.com/documentation/sessions/#setting-test-cookies


Hope that helps.

Regards
Darryl



signature.asc
Description: OpenPGP digital signature


Overriding model __init__() method

2008-04-28 Thread Nathaniel Whiteinge

I'm using the __init__() method in a few models to save state for
later use in save(), e.g.::

class MyModel(models.Model):
...
def __init__(self, *args, **kwargs):
super(MyModel, self).__init__(*args, **kwargs)
self.old_value = self.value
def save(self):
if self.old_value != self.value:
...
super(MyModel, self).save()

But that functionality seems to have broken in the last week. It
appears that __init__() isn't be called (as often?) as it used to. I'm
on the GIS branch and it seems to have broken on r7482 (qs-rf merge).

I'm on deadline this week, and don't have much time to play with a
small test app on trunk, but I use this technique in other projects,
so I was wondering if this method an ok way to check for changes
between model saves and there's a bug somewhere, or am I doing
something fragile that should be done another way?

- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Intermediary Triple Join Table?

2008-04-28 Thread Russell Keith-Magee

On Tue, Apr 29, 2008 at 4:31 AM, phloopy <[EMAIL PROTECTED]> wrote:
>
>  It looks like Rails has something called Has Many Through that can
>  address such a triple join table.  Still no idea how to do it in
>  Django though...

Right now - like this:

http://www.djangoproject.com/documentation/models/m2m_intermediary/

Longer term, we're working on this:

http://code.djangoproject.com/ticket/6095

Yours
Russ Magee %-)

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



Re: Complex Django Hosting

2008-04-28 Thread Martin Diers


On Apr 27, 2008, at 10:42 AM, Josh wrote:

>
> So it sounds like the best three options are (in no particular order):
> 1. Remain with Webfaction.
> 2. Move to Slicehost.
> 3. Move to a colocated server.
>

If you are looking at colocation, have you checked out Amazon EC2? It  
might be a much more viable option. You could setup server instances,  
and only bring them up as you need them. Easiest way to scale there  
is. I hear they are lowering their data transfer prices, which would  
make it competitive with the best of the dedicated hosts out there.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Genealogy apps

2008-04-28 Thread Milan Andric



On Apr 28, 12:32 pm, ecrosstexas <[EMAIL PROTECTED]> wrote:
> Does anyone know of any existing apps writtrn in Django for
> genealogy?  I thought there was one in Google Code awhile back, but I
> can't seem to find it now.

I've heard of one called begat but it may have disappeared from google
code.

http://begat.google.com/

Here's the project from a while ago, maybe you can contact the
original author.

http://andric.us/media/begat.zip

--
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: form_for_model and accessing foreign object attribute

2008-04-28 Thread morfeus

Everyone,

Wow! Thanks for the speedy response. I only wish I had thrown in the
towel days ago and posted here. I could have saved a lot of time! Oh
well, I did learn a lot.

Richard, I tried to implement your solution but I get the error:
'global name 'Manager' is not defined'
I tried adding an import of Manager to the model as well in the view,
but that didn't have any effect.

Karen, I used your solution and it worked great. In fact, I kept
telling myself the answer would be something very easy, and it was. To
answer your question, I was just sending the manager email address as
the body for testing purposes. I wanted to see the value that was
getting passed.

Thanks again both of you, for your input. I hope I can one day be of
help to someone else!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Intermediary Triple Join Table?

2008-04-28 Thread Cameron Hutchison

phloopy wrote:

>I'm building a system that manages sports leagues, hockey is the first
>one I'm worried about but I intend it to be flexible enough for others
>as well.  There are three objects that are involved in this question:

>Person: represents anybody involved in the league, has many roles
>(that is, Person's role = models.ManyToManyField(Roles))

>Role: Any given person can be a number of roles in the app. [...]

>Game: A game is many-to-many with Person (Game's people =
>models.ManyToManyField(Person)), but for any given person related to
>the game it must be specified what their role is for that game.  They
>cannot be both a player and a ref, for example.

>If I weren't using django models I'd create a intermediary triple join
>table, with fields for player, role, and game.  I can't conceive how
>to do such a thing with Django though, since the intermediary join
>tables are done behind the scenes with ManyToMany relationships and
>seem to support two way relationships only.

You can use an explicit intermediary join model:

class GameParticipant(models.Model):
game = models.ForeignKey(Game)
person = models.ForeignKey(Person)
role = models.ForeignKey(Role)

class Meta:
unique_together = [('game', 'person')]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: unable to open database file

2008-04-28 Thread Kenneth Gonsalves


On 29-Apr-08, at 1:52 AM, [EMAIL PROTECTED] wrote:

> I get a operational error when i try to access the sqlite3 database  
> file. This doesn't happen with Django built in server only with  
> apache. The file has 660 permission so i dont know why it cant be  
> opened everything else works fine. OS is openSUSE 10.3

does apache have write permission on the directory containing the  
sqllite database file - apache needs write permision for both the  
file and the parent directory

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: UnicodeDecodeError in request.get_full_path()

2008-04-28 Thread Amit Ramon

Sorry, it was me being foolish. I created a query string that was utf-8 encoded 
with non-ascii characters, and used it in a template anchor tag. It seems that 
Firefox converts it according to RFC 2396 before sending it over, but IE leaves 
it as is. request.get_full_path expects to receive an ascii string rightfully 
(so the P.s. of my original post is stupid, too), so it screams on utf-8. It 
happens in all environments, depending on the browser. I fixed my code to 
convert the string using urllib.quote_plus and everything is working fine.

Thanks,

Amit


* Amit Ramon <[EMAIL PROTECTED]> [2008-04-27 20:59 +0300]:
> Hi,
> 
> I'm getting a random, wierd UnicodeDecodeError when calling 
> request.get_full_path() in one of my views. This specific view displays some 
> search reaults, and the error always occurs when a user selects the second 
> results page (results are paginated).
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Genealogy apps

2008-04-28 Thread Kenneth Gonsalves


On 28-Apr-08, at 11:02 PM, ecrosstexas wrote:

> Does anyone know of any existing apps writtrn in Django for
> genealogy?  I thought there was one in Google Code awhile back, but I
> can't seem to find it now.

is the year 1900 problem solved? if not , genealogy would be a little  
difficult

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: making a stand-alone program call a django app directly

2008-04-28 Thread [EMAIL PROTECTED]

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

On Apr 28, 5:10 pm, "Andrew D. Ball" <[EMAIL PROTECTED]> wrote:
> Greetings.
>
> I'm working on a Django application and would like
> to be able to write a stand-alone Python program
> that calls my Django application directly.
>
> Accomplishing like seems to require me to import
> the project settings file, which I've figured out
> how to do.  However, I'm still looking for how
> to satisfy the rest of the requirements (which
> are probably what 'python manage.py shell'
> does for me...).
>
> I have the Python script in the application's
> directory and am using some silly manipulation
> of sys.path to import the module named 'settings'
> in the previous directory (which is the Django
> project directory).
>
> It looks like I need to set some environment
> variables.  Here's the error message I'm getting
> when I try to import the application's models:
>
> [EMAIL PROTECTED]:$ python batch_process.py
> Traceback (most recent call last):
>   File "batch_process.py", line 16, in ?
>     import models
>   File 
> "/home/nfs/aball/devel/power_reg/trunk/power_reg_2/pr2_core_services/models.py",
>  line 6, in ?
>     from django.db import models
>   File "/var/lib/python-support/python2.4/django/db/__init__.py", line 7, in ?
>     if not settings.DATABASE_ENGINE:
>   File "/var/lib/python-support/python2.4/django/conf/__init__.py", line 28, 
> in __getattr__
>     self._import_settings()
>   File "/var/lib/python-support/python2.4/django/conf/__init__.py", line 53, 
> in _import_settings
>     raise EnvironmentError, "Environment variable %s is undefined." % 
> ENVIRONMENT_VARIABLE
> EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.
>
> Anybody know how to do this?
>
> Thanks for your help.
>
> Peace,
> Andrew
> =
> Andrew D. Ball <[EMAIL PROTECTED]>
> software engineer
> American Research Institute, Inc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



making a stand-alone program call a django app directly

2008-04-28 Thread Andrew D. Ball

Greetings.

I'm working on a Django application and would like
to be able to write a stand-alone Python program
that calls my Django application directly.

Accomplishing like seems to require me to import
the project settings file, which I've figured out
how to do.  However, I'm still looking for how
to satisfy the rest of the requirements (which
are probably what 'python manage.py shell'
does for me...).

I have the Python script in the application's
directory and am using some silly manipulation
of sys.path to import the module named 'settings'
in the previous directory (which is the Django
project directory).

It looks like I need to set some environment
variables.  Here's the error message I'm getting
when I try to import the application's models:

[EMAIL PROTECTED]:$ python batch_process.py 
Traceback (most recent call last):
  File "batch_process.py", line 16, in ?
import models
  File 
"/home/nfs/aball/devel/power_reg/trunk/power_reg_2/pr2_core_services/models.py",
 line 6, in ?
from django.db import models
  File "/var/lib/python-support/python2.4/django/db/__init__.py", line 7, in ?
if not settings.DATABASE_ENGINE:
  File "/var/lib/python-support/python2.4/django/conf/__init__.py", line 28, in 
__getattr__
self._import_settings()
  File "/var/lib/python-support/python2.4/django/conf/__init__.py", line 53, in 
_import_settings
raise EnvironmentError, "Environment variable %s is undefined." % 
ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.

Anybody know how to do this?

Thanks for your help.

Peace,
Andrew
=
Andrew D. Ball <[EMAIL PROTECTED]>
software engineer
American Research Institute, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing dictionary values in a template for loop

2008-04-28 Thread RaviKondamuru

Figured out. {{ values|length }} gives the length of the list to be
used for rowspan tag.
thanks,
Ravi.

On Apr 28, 1:16 pm, RaviKondamuru <[EMAIL PROTECTED]> wrote:
> Thanks. With results.items, both solutions work on the svn current
> version.
>
> The variable value is a list. I would like each key,value to be in a
> separate row.
>
> {% for key, values in results.items %}
>  {% for value in values %}
>   
> {{ key }}
> {{ value }}
>   
>  {% endfor %}
> {% endfor %}
>
> This causes the same key to showup on all the rows associated with it.
> Is there a way to use html's colspan to have the key cell span all
> rows associated with it?
>
> thanks,
> Ravi.
>
> On Apr 27, 4:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Sun, 2008-04-27 at 13:35 -0500, Alex Ezell wrote:
>
> > [...]
>
> > > Depending on the version of Django you are using, you should be able to 
> > > do this:
>
> > > {% for key, value in results %}
> > >   
> > > {{ key }}
> > > {{ value }}
> > >   
> > > {% endfor %}
>
> > Or, for older versions:
>
> > {% for item in results.items %}
> >   
> > {{ item.0 }} {# key #}
> > {{ item.1 }} {# value #}
> >   
> > {% endfor %}
>
> > (by the way, the original example should have used results.items, too.)
>
> > Regards,
> > Malcolm
>
> > --
> > How many of you believe in telekinesis? Raise my 
> > hand...http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Render raw image

2008-04-28 Thread hareesh

(I'm a django n00b).

Through a database, I get the raw contents of an image and the image's
mimetype:

def Welcome(request):
  (mime, blob) = d.GetMedia()
  ...
  return shortcuts.render_to_response('welcome.html', { 'msg'  :
'Welcome!', 'logo' : blob }) # Line 3

Now clearly, this (Line 3) doesn't work as I intend it to. So what is
the best way of showing the raw image? Must I write it to my "static
files" directory and then pass the full path of the newly written
image, to the context dict in render_to_response?

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: form_for_model and accessing foreign object attribute

2008-04-28 Thread Karen Tracey
On Mon, Apr 28, 2008 at 5:20 PM, Richard Dahl <[EMAIL PROTECTED]> wrote:

>
> You are having trouble because the form does not contain a Manager
> object, it contains the primary key of a related Manager object.
>
>
Actually, form.cleaned_data['manager'] will be a Manager object.  That's
what cleaning does -- transforms the POSTed primary key value into the
associated model object.

Which means that:

message = form.cleaned_data['manager'].email
send_mail(
'Software Request', message,
sender, ['[EMAIL PROTECTED]']
)

should work.  (Assuming what you want to send is a message consisting of the
manager's email address, which seems a little confusing.  Or is this really
what you mean to put in place of the hardcoded 'mitchell' for the
destination address?)

Karen

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



Processing saves()

2008-04-28 Thread Lee Hinde

I'd like to make sure I'm on the right track.

Given a standard Invoice/Work order type app, where one model is the
Work Order and one is Line Items.

When I save line items, I want to calculate extended price (Quantity *
cost). Put that in the Line Items model, def save()

After the line item is saved, I want to call the Work Order to have it
update a Total Due column. Assuming I have the code in the Work Order
model to get all the related line items and sum the extended price,
what I would do is call the Work Order save() method from the Line
Item save() methd, after calling the super(save).

That is:

class LineItems(models.Model):
item = models.CharField(max_length=100)
wo = models.ForeignKey(WorkOrder)

def save(self):
doLocalMath()
super(LineItems, self).save()
WorkOrder.save()

And, sort of related,  I need to call custom SQL to get the sum of
related records, correct?

Thanks.

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



Re: form_for_model and accessing foreign object attribute

2008-04-28 Thread Richard Dahl

You are having trouble because the form does not contain a Manager
object, it contains the primary key of a related Manager object.

try this:

m = Manager.objects.get(pk=form['manager'])
send_mail(
 'Software Request', message,
sender, m.email)
-richard


On 4/28/08, morfeus <[EMAIL PROTECTED]> wrote:
>
> I am new to django and python, so forgive me if I make incorrect
> references. I've been trying for days to find a solution. I will try
> to give all the necessary details.
>
> The general problem:
> Accessing an attribute value of a foreign object through the form.
>
> What I have:
> A form that gathers information and upon submission adds a record to
> the database and sends out an email. I am creating the form with
> form_for_model. A basic version of the model is:
>
> class Software_request(models.Model):
>manager = models.ForeignKey(Manager)
>fname = models.CharField("First name", max_length=15)
>lname = models.CharField("Last name", max_length=15)
>email = models.EmailField()
>software = models.CharField(max_length=50)
>
>class Admin:
>list_display = ('lname', 'fname', 'software', 'manager')
>list_filter = [''manager']
>search_fields = ['software']
>
>def __unicode__(self):
>return '%s, %s' % (self.lname, self.fname)
>
> In addition, you will notice the manager is a ForeignKey to this:
> class Manager(models.Model):
>fname = models.CharField("First name", max_length=15)
>lname = models.CharField("Last name", max_length=15)
>email = models.EmailField()
>
>class Admin:
>pass
>
>def __unicode__(self):
>return'%s, %s' % (self.lname, self.fname)
>
> And of course my view looks like this:
>
> from django.http import HttpResponseRedirect, HttpResponse
> from django.shortcuts import render_to_response
> from django.template import Context, loader
> from django.core.mail import send_mail
> from forms import RequestForm
>
> def sw_request(request):
>if request.method == 'POST':
>form = RequestForm(request.POST)
>if form.is_valid():
>sender = form.cleaned_data['email']
># message = form['manager']
>message = form.cleaned_data['manager']
>send_mail(
>'Software Request', message,
>sender, ['[EMAIL PROTECTED]']
>)
>form.save()
>return HttpResponseRedirect('/sw_request/thanks/')
>else:
>form = RequestForm()
>return render_to_response('test2/sw_request.html', {'form': form})
>
> def thanks(request):
>return render_to_response('test2/thanks.html')
>
> You can see I have a line commented out in the view. I have been
> playing around with various ways of trying to get at the data. Once I
> figure it out, I will be using the manager's email as a recipient
> address. That's the only thing I cannot seem to get.
>
> What I have noticed:
> -The manager value in POST (when submitting the data) is the id number
> of the respective manager record. This makes sense because the
> software_request uses the id as the foreign key.
> -The drop down field in the form for managers, displays the unicode
> value of 'lastname, firstname' as expected(populated of course with
> all the values in the table).
>
> I have tried to set a variable to capture the manager's email but
> cannot. I have tried various things (laugh as necessary) like:
> mgr = form.manger.email
> mgr = form.manager.get('email')
> Usually the error page tells me that the 'manager' attribute does not
> exist.
>
> Is what I am attempting even possible? It seems very simple but no
> matter what I try I'm not doing it right. Thanks to anyone who can
> understand and help.
>
> PS- ask as many additional questions if you want. I'll be working on
> this all day...again :-\
> >
>

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



Re: authenicate

2008-04-28 Thread Chris

Sorry I was kind of vague on that. The error that I was getting was
the raise - 'Somethng Went Wrong'. But I did figure it out. The reason
for the error was related to another issue that I resolved. Thanks for
responding and being so supportive.


On Apr 28, 4:35 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Apr 28, 2008 at 4:01 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> > Anyone see what I am doing wrong here?
>
> >http://dpaste.com/47296/
>
> > Thanks in advance.
>
> You put some of your close parens in odd places.
>
> Not the kind of help you are looking for?  Perhaps include in your request
> for help a description of the error you are encountering, or how the
> behavior you are observing differs from what you expect, and the code for
> your login form and template referenced by the snippet you posted.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Intermediary Triple Join Table?

2008-04-28 Thread Richard Dahl

Based on what you have described I see no reason to tie a persons
sports role to them directly, by doing something like what I suggest
below, you tie a person to a role only when they use that role (during
a game).  If you think about it, this represents real life a bit more
accurately.  I played soccer (GK, mid-fielder, and forward at times)
and refereed soccer, as well as played basketball (guard) at times.

GameRoster(model):
gamerole = FK(GameRole)
person = FK(People)

Game(model):
personnel = M2M(GameRoster)

This way the roles are flexible (someone could be a Referee in one
game, a goalkeeper in another game and a scorekeeper in another game)
You could even build GameProfiles that would allow you create
validated game rosters (A hockey profile would allow you to put in
goalkeepers but a Football profile would not, unless you are not in
the US in which case a Football profile would allow goalkeepers but
not quarterbacks), and you could limit the number of any given roles
allowed, i.e. minimum number of referees, maximum number of
placekickers, etc...

this implies that you decouple league-roles from application roles, i.e.

GameRole = sports position
AppRole = Application permission role

HTH,
-richard



On 4/28/08, phloopy <[EMAIL PROTECTED]> wrote:
>
> I'm trying to figure out how to solve a particular problem in my Model
> design.  If I'm trying to pound a nail with an old shoe or glass
> bottle (google "Pounding A Nail: Old Shoe or Glass Bottle?") feel free
> to suggest a different way to tackle the problem.
>
> I'm building a system that manages sports leagues, hockey is the first
> one I'm worried about but I intend it to be flexible enough for others
> as well.  There are three objects that are involved in this question:
>
> Person: represents anybody involved in the league, has many roles
> (that is, Person's role = models.ManyToManyField(Roles))
> Role: Any given person can be a number of roles in the app.  Some
> examples are roles used for scheduling, such as player (member of a
> team), ref (multiple refs assigned to each game), scorekeeper, goalie
> (for leagues with rotating goalies), but roles would also be used for
> permissions on the app itself, such as Admin, or News Editor, etc.
>
> I'm fine with it up to that point, but getting the people and roles
> related to scheduled games is causing me problems.
>
> Game: A game is many-to-many with Person (Game's people =
> models.ManyToManyField(Person)), but for any given person related to
> the game it must be specified what their role is for that game.  They
> cannot be both a player and a ref, for example.
>
> If I weren't using django models I'd create a intermediary triple join
> table, with fields for player, role, and game.  I can't conceive how
> to do such a thing with Django though, since the intermediary join
> tables are done behind the scenes with ManyToMany relationships and
> seem to support two way relationships only.
>
> Is there a way to accomplish this design with Django Models?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Image Field problem, probably something to do with the path, but I'm not sure

2008-04-28 Thread mw

Hello,

I created a small little application that included a field for an
image upload in the admin interface.  It worked in the past, but after
changing the path of MEDIA_ROOT to

MEDIA_ROOT = '/Library/WebServer/Documents/site_media/'

It seems to no longer work.  That directory exists, and at the current
time it has full rwx permissions.


The admin page, however, keeps rejecting the images I try to send it
claiming that it is a bad or corrupt image.  This happens even with
images that I know for a fact have worked before.


Any ideas or help?

Thanks in advance,
mw
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



form_for_model and accessing foreign object attribute

2008-04-28 Thread morfeus

I am new to django and python, so forgive me if I make incorrect
references. I've been trying for days to find a solution. I will try
to give all the necessary details.

The general problem:
Accessing an attribute value of a foreign object through the form.

What I have:
A form that gathers information and upon submission adds a record to
the database and sends out an email. I am creating the form with
form_for_model. A basic version of the model is:

class Software_request(models.Model):
manager = models.ForeignKey(Manager)
fname = models.CharField("First name", max_length=15)
lname = models.CharField("Last name", max_length=15)
email = models.EmailField()
software = models.CharField(max_length=50)

class Admin:
list_display = ('lname', 'fname', 'software', 'manager')
list_filter = [''manager']
search_fields = ['software']

def __unicode__(self):
return '%s, %s' % (self.lname, self.fname)

In addition, you will notice the manager is a ForeignKey to this:
class Manager(models.Model):
fname = models.CharField("First name", max_length=15)
lname = models.CharField("Last name", max_length=15)
email = models.EmailField()

class Admin:
pass

def __unicode__(self):
return'%s, %s' % (self.lname, self.fname)

And of course my view looks like this:

from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render_to_response
from django.template import Context, loader
from django.core.mail import send_mail
from forms import RequestForm

def sw_request(request):
if request.method == 'POST':
form = RequestForm(request.POST)
if form.is_valid():
sender = form.cleaned_data['email']
# message = form['manager']
message = form.cleaned_data['manager']
send_mail(
'Software Request', message,
sender, ['[EMAIL PROTECTED]']
)
form.save()
return HttpResponseRedirect('/sw_request/thanks/')
else:
form = RequestForm()
return render_to_response('test2/sw_request.html', {'form': form})

def thanks(request):
return render_to_response('test2/thanks.html')

You can see I have a line commented out in the view. I have been
playing around with various ways of trying to get at the data. Once I
figure it out, I will be using the manager's email as a recipient
address. That's the only thing I cannot seem to get.

What I have noticed:
-The manager value in POST (when submitting the data) is the id number
of the respective manager record. This makes sense because the
software_request uses the id as the foreign key.
-The drop down field in the form for managers, displays the unicode
value of 'lastname, firstname' as expected(populated of course with
all the values in the table).

I have tried to set a variable to capture the manager's email but
cannot. I have tried various things (laugh as necessary) like:
mgr = form.manger.email
mgr = form.manager.get('email')
Usually the error page tells me that the 'manager' attribute does not
exist.

Is what I am attempting even possible? It seems very simple but no
matter what I try I'm not doing it right. Thanks to anyone who can
understand and help.

PS- ask as many additional questions if you want. I'll be working on
this all day...again :-\
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to open database file

2008-04-28 Thread [EMAIL PROTECTED]

What are the permissions of the enclosing folder? See
http://code.djangoproject.com/wiki/NewbieMistakes#DjangosaysUnabletoOpenDatabaseFilewhenusingSQLite3

On Apr 28, 4:22 pm, [EMAIL PROTECTED] wrote:
> hello all,
>
> I get a operational error when i try to access the sqlite3 database file. 
> This doesn't happen with Django built in server only with apache. The file 
> has 660 permission so i dont know why it cant be opened everything else works 
> fine. OS is openSUSE 10.3.
>
> Regards,
>
> Jorge Hugo Murillo
> 
>
>       
> 
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: generic delete_object issue on Firefox (redirect bug)

2008-04-28 Thread koenb

Sorry;

forgot to add, you will need to wrap the generic view in a custom
wrapper view for that.



On 28 apr, 22:42, koenb <[EMAIL PROTECTED]> wrote:
> The problem is FF does not like it if you do not consume the POST
> data.
> Just add the line
> request.POST
> somewhere in your view before redirecting.
>
> Koen
>
> On 28 apr, 17:33, yml <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > I noticed a very strange behavior with the generic view called :
> > "delete_object". The symptom is the following :
> >   * Firefox return an error message
> > ---8<---
> > The connection was reset
>
> > The connection to the server was reset while the page was loading.
>
> > *   The site could be temporarily unavailable or too busy. Try
> > again in a few
> >   moments.
>
> > *   If you are unable to load any pages, check your computer's
> > network
> >   connection.
>
> > *   If your computer or network is protected by a firewall or
> > proxy, make sure
> >   that Firefox is permitted to access the Web.
> > --->8---
> > It seems that the bug is in Firefox code. The same code is working
> > fine on IE 6.0 and Opéra, I am testing this on windows.
>
> > My code look like this (extracted form urls.py):
> > ---8<---
> >  url(r'^delete/(?P[-\w]+)/$', delete_object,
> > {"model":Survey,
> >  "post_delete_redirect": "/survey/editable/",
> >  "template_object_name":"survey",
> >  "login_required": True,
> >  'extra_context': {'title': _('Delete survey')}
> > },
> > name='survey-delete'),
> > --->8---
> > It would be nice if someone could help me with a workaround or a
> > solution.
>
> > Should I report issues in the django bug tracker ?
> > Thank you for your help.
> > --yml
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: generic delete_object issue on Firefox (redirect bug)

2008-04-28 Thread koenb

The problem is FF does not like it if you do not consume the POST
data.
Just add the line
request.POST
somewhere in your view before redirecting.

Koen

On 28 apr, 17:33, yml <[EMAIL PROTECTED]> wrote:
> Hello,
> I noticed a very strange behavior with the generic view called :
> "delete_object". The symptom is the following :
>   * Firefox return an error message
> ---8<---
> The connection was reset
>
> The connection to the server was reset while the page was loading.
>
> *   The site could be temporarily unavailable or too busy. Try
> again in a few
>   moments.
>
> *   If you are unable to load any pages, check your computer's
> network
>   connection.
>
> *   If your computer or network is protected by a firewall or
> proxy, make sure
>   that Firefox is permitted to access the Web.
> --->8---
> It seems that the bug is in Firefox code. The same code is working
> fine on IE 6.0 and Opéra, I am testing this on windows.
>
> My code look like this (extracted form urls.py):
> ---8<---
>  url(r'^delete/(?P[-\w]+)/$', delete_object,
> {"model":Survey,
>  "post_delete_redirect": "/survey/editable/",
>  "template_object_name":"survey",
>  "login_required": True,
>  'extra_context': {'title': _('Delete survey')}
> },
> name='survey-delete'),
> --->8---
> It would be nice if someone could help me with a workaround or a
> solution.
>
> Should I report issues in the django bug tracker ?
> Thank you for your help.
> --yml
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: authenicate

2008-04-28 Thread Karen Tracey
On Mon, Apr 28, 2008 at 4:01 PM, Chris <[EMAIL PROTECTED]> wrote:

>
> Anyone see what I am doing wrong here?
>
> http://dpaste.com/47296/
>
> Thanks in advance.
>

You put some of your close parens in odd places.

Not the kind of help you are looking for?  Perhaps include in your request
for help a description of the error you are encountering, or how the
behavior you are observing differs from what you expect, and the code for
your login form and template referenced by the snippet you posted.

Karen

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



Re: Intermediary Triple Join Table?

2008-04-28 Thread phloopy

It looks like Rails has something called Has Many Through that can
address such a triple join table.  Still no idea how to do it in
Django though...

On Apr 28, 2:47 pm, phloopy <[EMAIL PROTECTED]> wrote:
> I'm trying to figure out how to solve a particular problem in my Model
> design.  If I'm trying to pound a nail with an old shoe or glass
> bottle (google "Pounding A Nail: Old Shoe or Glass Bottle?") feel free
> to suggest a different way to tackle the problem.
>
> I'm building a system that manages sports leagues, hockey is the first
> one I'm worried about but I intend it to be flexible enough for others
> as well.  There are three objects that are involved in this question:
>
> Person: represents anybody involved in the league, has many roles
> (that is, Person's role = models.ManyToManyField(Roles))
> Role: Any given person can be a number of roles in the app.  Some
> examples are roles used for scheduling, such as player (member of a
> team), ref (multiple refs assigned to each game), scorekeeper, goalie
> (for leagues with rotating goalies), but roles would also be used for
> permissions on the app itself, such as Admin, or News Editor, etc.
>
> I'm fine with it up to that point, but getting the people and roles
> related to scheduled games is causing me problems.
>
> Game: A game is many-to-many with Person (Game's people =
> models.ManyToManyField(Person)), but for any given person related to
> the game it must be specified what their role is for that game.  They
> cannot be both a player and a ref, for example.
>
> If I weren't using django models I'd create a intermediary triple join
> table, with fields for player, role, and game.  I can't conceive how
> to do such a thing with Django though, since the intermediary join
> tables are done behind the scenes with ManyToMany relationships and
> seem to support two way relationships only.
>
> Is there a way to accomplish this design with Django Models?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sort QuerySet

2008-04-28 Thread Poz

Thanks to you both. I'll try them and see if I can get this working.

~poz

On Apr 28, 12:42 am, Amit Ramon <[EMAIL PROTECTED]> wrote:
> * Malcolm Tredinnick <[EMAIL PROTECTED]> [2008-04-28 16:17 +1000]:
>
>
>
>
>
> > On Sun, 2008-04-27 at 23:03 -0700, Poz wrote:
> > [...]
> > > I'm going crazy with this problem. Anyone know how to sort a QuerySet
> > > with an attribute that's not part of the database?? Transform it into
> > > l list?
>
> > Precisely. Since you can't do the sorting at the database level, you
> > have to sort at the Python level. Which means giving the sort function
> > access to all the data (it's possible to write a sorting function that
> > produces sorted output as the results are pulled from an iterator, but
> > it's performance isn't great).
>
> > Sort convert your data to a list and then use list sorting. You'll need
> > to pass in the "key" attribute in Python 2.5, or pass in a cmp function
> > in all versions of Python, but at that point it's simply normal list
> > sorting.
>
> > Regards,
> > Malcolm
>
> > --
> > What if there were no hypothetical questions?
> >http://www.pointy-stick.com/blog/
>
> I think it might be possible to achieve that using QuerySet's extra() method. 
> It might depend on the specific details, but if you can write a SQL that 
> computes the score for a movie, you can add it to the selected columns and 
> order by it. I'm doing something similar and it's working well.
>
> It goes along the following lines:
>
> # write a SQL select statement that calculate the score for a given movie:
> score_sql = ". "
> # use extra() to add a column to the selected columns, and order by it:
> movies_queryset = Movie.objects.extra(select={'score': 
> score_select}).order_by('score')
>
> Note that there is a ticket for a bug when a select in extra has parameters
>  (i.e. extra(select={...}, params=[...]), so be aware of that (you don't have 
> to use params).
>
> If you can do it that way, it may be better than using a python list. The 
> performance of doing it in the database might be better, and besides, you 
> cannot always pass python lists to some generic views instead of query sets. 
> E.g., object_list cannot take a list.
>
> Hope this helps,
>
> Amit
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: authenicate

2008-04-28 Thread Poz

What kind of error are you getting?

On Apr 28, 1:01 pm, Chris <[EMAIL PROTECTED]> wrote:
> Anyone see what I am doing wrong here?
>
> http://dpaste.com/47296/
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



unable to open database file

2008-04-28 Thread jorgehugoma
hello all,

I get a operational error when i try to access the sqlite3 database file. This 
doesn't happen with Django built in server only with apache. The file has 660 
permission so i dont know why it cant be opened everything else works fine. OS 
is openSUSE 10.3.

 
Regards,


Jorge Hugo Murillo



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Enhancing the Admin Interface

2008-04-28 Thread Kevin Monceaux

James,

On Mon, 28 Apr 2008, James Matthews wrote:

> Can someone please point me to a site that lists all the enhancement for
> the admin interface. (filter lists,search,orderby etc..)

They're on the Model Reference documentation page:

http://www.DjangoProject.com/documentation/model-api/#admin-options

It seems like there would be a separate documentation page dedicated to 
admin customization.  I had a little trouble finding the above myself.

If you're using newforms-admin, there's quite a few customization tips on 
the newforms-admin howto page:

http://code.DjangoProject.com/wiki/NewformsHOWTO



Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

Si hoc legere scis nimium eruditionis habes.
Longum iter est per praecepta, breve et efficax per exempla!!!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing dictionary values in a template for loop

2008-04-28 Thread RaviKondamuru

Thanks. With results.items, both solutions work on the svn current
version.

The variable value is a list. I would like each key,value to be in a
separate row.

{% for key, values in results.items %}
 {% for value in values %}
  
{{ key }}
{{ value }}
  
 {% endfor %}
{% endfor %}

This causes the same key to showup on all the rows associated with it.
Is there a way to use html's colspan to have the key cell span all
rows associated with it?

thanks,
Ravi.

On Apr 27, 4:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-04-27 at 13:35 -0500, Alex Ezell wrote:
>
> [...]
>
> > Depending on the version of Django you are using, you should be able to do 
> > this:
>
> > {% for key, value in results %}
> >   
> > {{ key }}
> > {{ value }}
> >   
> > {% endfor %}
>
> Or, for older versions:
>
> {% for item in results.items %}
>   
> {{ item.0 }} {# key #}
> {{ item.1 }} {# value #}
>   
> {% endfor %}
>
> (by the way, the original example should have used results.items, too.)
>
> Regards,
> Malcolm
>
> --
> How many of you believe in telekinesis? Raise my 
> hand...http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Performance Discoveries Part 1

2008-04-28 Thread James Matthews
Very nice article! Thanks

2008/4/28 Graham Dumpleton <[EMAIL PROTECTED]>:

>
> On Apr 28, 5:44 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > Christian Vest Hansen napisał(a):
> >
> > > On 4/28/08, rich <[EMAIL PROTECTED]> wrote:
> > >>  Yes, I too am at a similar level of confusion as to when django is
> not
> > >>  thread safe.
> >
> > > With the python GIL, is it even possible to create a python program
> > > that isn't thread-safe? I thought that was the whole point of having a
> > > GIL in the first place; make concurrency a non-issue.
> >
> > Yes, it is still possible. Create an object with global state, alter it
> > from different threads without locking and there you go, the state of
> > object is not consistent (threads can not rely on the state), you might
> > even get race condition. GIL protects only internal state of VM, not
> > your objects' state.
>
> Correct. For some background on when multithreading issues apply with
> mod_wsgi, see:
>
>  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
>
> In particular, for any configuration where wsgi.multithread is True,
> you need to know your code is thread safe.
>
> The document includes a brief summary at the end about building
> portable applications that can deal with both multithread and
> multiprocess web servers.
>
> Graham
> >
>


-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
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
-~--~~~~--~~--~--~---



Enhancing the Admin Interface

2008-04-28 Thread James Matthews
Dear List

Can someone please point me to a site that lists all the enhancement for the
admin interface. (filter lists,search,orderby etc..)

Thanks
James

-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
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
-~--~~~~--~~--~--~---



authenicate

2008-04-28 Thread Chris

Anyone see what I am doing wrong here?

http://dpaste.com/47296/

Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Intermediary Triple Join Table?

2008-04-28 Thread phloopy

I'm trying to figure out how to solve a particular problem in my Model
design.  If I'm trying to pound a nail with an old shoe or glass
bottle (google "Pounding A Nail: Old Shoe or Glass Bottle?") feel free
to suggest a different way to tackle the problem.

I'm building a system that manages sports leagues, hockey is the first
one I'm worried about but I intend it to be flexible enough for others
as well.  There are three objects that are involved in this question:

Person: represents anybody involved in the league, has many roles
(that is, Person's role = models.ManyToManyField(Roles))
Role: Any given person can be a number of roles in the app.  Some
examples are roles used for scheduling, such as player (member of a
team), ref (multiple refs assigned to each game), scorekeeper, goalie
(for leagues with rotating goalies), but roles would also be used for
permissions on the app itself, such as Admin, or News Editor, etc.

I'm fine with it up to that point, but getting the people and roles
related to scheduled games is causing me problems.

Game: A game is many-to-many with Person (Game's people =
models.ManyToManyField(Person)), but for any given person related to
the game it must be specified what their role is for that game.  They
cannot be both a player and a ref, for example.

If I weren't using django models I'd create a intermediary triple join
table, with fields for player, role, and game.  I can't conceive how
to do such a thing with Django though, since the intermediary join
tables are done behind the scenes with ManyToMany relationships and
seem to support two way relationships only.

Is there a way to accomplish this design with Django Models?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Edit textarea in openoffice?

2008-04-28 Thread Michael

Hi All,

Up to now using tinymce ( and xinha) to modify content of textarea (
it is a letter ) .

Now need to switch for editing that content in openoffice ( word ) and
able to save it back to textarea.
Is it possible ?

Or which way should I go ?

-- 
--
Michael

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Great article about web2py

2008-04-28 Thread kamil

thanx
interesting

On Apr 28, 6:19 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> This is not Django specific but it is framework relevant.  I thought
> this was a great writeup of features for any framework.  At least I am
> one person who likes the features of this web2py framework.
>
> http://mdp.cti.depaul.edu/examples/static/web2py_vs_others.pdf
>
> Web2py makes development happen faster because people can get up and
> running quickly.  I have only played with it enough to be amazed.  It
> allows the less technical disciplines like designers, journalists and
> web producers to start building or collaborating with web based
> database driven apps.
>
> The difficulty for my organization (News21) is the biggest technical
> problem which is integrating different technologies like flash and
> javascript.  It is difficult to do when each discipline has their own
> tools and technologies that don't integrate well. I think this is one
> step closer to making these different disciplines work better.
>
> --
> 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: Page-trees in admin system

2008-04-28 Thread Matthias Kestenholz

Hi,

On Mon, 2008-04-28 at 12:19 -0700, Rodrigo Culagovski wrote:
> Matthias,
> 
> that looks like what I'm looking for. Does it work in trunk?
> 
> thanks!
> 
> Rodrigo

I've just made an update to trunk locally and it seems to work, yeah.
django-mptt does not seem to have a problem with the qs-rf merge, and
I'm not using any special features of Django...

Please note that this is very much a work in progress. You are very
welcome to help out (of course) and I am also happy to answer questions
about the code or the use of it, but note that some things might have to
be changed. I'm using it in production for a few small sites already, so
it isn't too bad for sure.

Matthias

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Page-trees in admin system

2008-04-28 Thread Rodrigo Culagovski

Matthias,

that looks like what I'm looking for. Does it work in trunk?

thanks!

Rodrigo

On Apr 28, 3:13 pm, Matthias Kestenholz <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
>
> On Mon, 2008-04-28 at 12:03 -0700, Rodrigo Culagovski wrote:
> > I am starting to develop a site with Django. I will need to implement
> > a 'pagetree' that serves static pages, (similar to the
> > contrib.flatpages), with 3 or 4 levels of depth. I have already done
> > this for previous Django driven sites, but wonder if there is a better
> > way.
>
> > My model looks like:
>
> > class Page(models.Model):
> > slug= models.SlugField(unique=True)
> > title= models.CharField(max_length=200, blank=True,null=True)
> > content= models.TextField()
> > create_date = models.DateTimeField(auto_now_add=True)
> > modify_date = models.DateTimeField(auto_now=True)
> > order= models.IntegerField()
> > subpages = models.ManyToManyField('self', symmetrical = False,
> > blank=True)
>
> > So I can add as many subpages (or sub-sub-, etc.) as I need. The order
> > of the pages in a sub-branch is specified the 'order' field, which
> > again is not super intuitive, and clumsy if you decide that the first
> > page is now the 7th one. It works, just not as smoothly as you'd like.
> > The way this is expressed in the admin, however, is not very intuitive
> > or useful, as you can't visualize the whole tree or make changes at
> > the tree level (such as drag a subbranch from one top-level page to
> > another). You can of course make changes in each individual page or
> > subpage, but not with a broader more general perspective.
> > It would be nice, for example, to be able to see (within the admin
> > view) a page's whole n-level sub-tree, and add or edit pages within
> > that tree. Or move up 1 level to the page's parent. Or change the
> > order of subpages.
>
> > Has anybody implemented a better system for page-trees?
>
> Yes, indeed, but it's not finished nor very clean yet. (And
> documentation is lacking, as always...) I've used django-mptt[1] and the
> jquery nestedsortablewidget[2] to create a page tree for a simple CMS.
> The code can be found in my git repository[3].
>
> Mabye you'll find something interesting there.
>
> [1]:http://code.google.com/p/django-mptt/
> [2]:http://code.google.com/p/nestedsortables/
> [3]:http://spinlock.ch/pub/git/?p=django/tusk.git;a=summary
>
>  screenshot1.png
> 63KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Genealogy apps

2008-04-28 Thread Jonathan
I use gramps.  I guess it would be cool to port to django. --Jonathan

On Mon, Apr 28, 2008 at 10:32 AM, ecrosstexas <[EMAIL PROTECTED]> wrote:

>
> Does anyone know of any existing apps writtrn in Django for
> genealogy?  I thought there was one in Google Code awhile back, but I
> can't seem to find it now.
> >
>


-- 
If I'm curt with you, it's because time is a factor here. I think fast, I
talk fast, and I need you guys to act fast if you want to get out of this.
So, pretty please, with sugar on top...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



get_or_create and foreign keys

2008-04-28 Thread Thierry

The get or create syntax does not appear to support the following
syntax:

object, created = get_or_create(entity_id = 12)

it fails on the _id part.
is there anyway to give it numbers instead of objects?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Page-trees in admin system

2008-04-28 Thread Rodrigo Culagovski

I am starting to develop a site with Django. I will need to implement
a 'pagetree' that serves static pages, (similar to the
contrib.flatpages), with 3 or 4 levels of depth. I have already done
this for previous Django driven sites, but wonder if there is a better
way.

My model looks like:

class Page(models.Model):
slug= models.SlugField(unique=True)
title= models.CharField(max_length=200, blank=True,null=True)
content= models.TextField()
create_date = models.DateTimeField(auto_now_add=True)
modify_date = models.DateTimeField(auto_now=True)
order= models.IntegerField()
subpages = models.ManyToManyField('self', symmetrical = False,
blank=True)

So I can add as many subpages (or sub-sub-, etc.) as I need. The order
of the pages in a sub-branch is specified the 'order' field, which
again is not super intuitive, and clumsy if you decide that the first
page is now the 7th one. It works, just not as smoothly as you'd like.
The way this is expressed in the admin, however, is not very intuitive
or useful, as you can't visualize the whole tree or make changes at
the tree level (such as drag a subbranch from one top-level page to
another). You can of course make changes in each individual page or
subpage, but not with a broader more general perspective.
It would be nice, for example, to be able to see (within the admin
view) a page's whole n-level sub-tree, and add or edit pages within
that tree. Or move up 1 level to the page's parent. Or change the
order of subpages.

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



Re: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread Don Spaulding II


Malcolm Tredinnick wrote:
> I merged queryset-refactor into trunk just now. This was changeset
> r7477.
Thanks for all of your effort on this, Malcolm.


Malcolm's Amazon Wishlist:
http://www.amazon.com/gp/registry/registry.html?ie=UTF8=wishlist=1VB5A16R2KV0T
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: multiple children in multitable inheritance

2008-04-28 Thread AmanKow

Thanks Malcolm!

Extending a model you don't own was the use case I was missing.
Thanks for clearing that up for me.

As I stated previously, I will be using explicit one to ones for the
person can be a student, faculty, manager, etc.  It looks like I could
hammer mt inheritance to fit without too much trouble, but using it
outside of it's intended area is just looking for trouble.  If not
now, then in the future.

I was unaware of a behind the scenes select_related, I stand happily
corrected!

I will definitely use the type field and/or relation idea when I need
to query a parent and treat the objects in an explicitly polymorphic
way.

The example I saw came up in irc, an individual had the need to query
and date sort an archive of File model (the parent) and go through the
list and treat articles, pictures, movies, audios etc. differently
(the children).  Wanting to fetch a qs based on parental info across
all children, and then needing to treat different children
differently, or have them act polymorphically, doesn't really seem
like an edge case to me.  But I can see that it would be a bear to
implement in a generic way and might best be solved for a given
applications needs.

Ah, the intricacies of ORM.  It makes my head hurt!

Thanks again,
Wayne


On Apr 28, 1:15 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-04-27 at 21:43 -0700, AmanKow wrote:
> > Thanks for the reply, Malcolm.
>
> > Between what you wrote above and just creating the models and looking
> > at the tables and indexes generated clarified the whole thing for
> > me...
>
> > My purposes are similar to what I was attempting with the above
> > example, with people instead of places (they can be any or all of
> > faculty, students and managers).  I thought that I could get some
> > sugar from multitable inheritance, but I guess I will be using
> > explicit OneToOneFields for this situation instead.
>
> > BTW, the db-api docs 
> > athttp://www.djangoproject.com/documentation/db-api/#one-to-one-relatio...
> > still state that OneToOneField should not be used, as its semantics
> > are in flux.  Can I assume that is no longer a true statement?
>
> It's no longer true. I overlooked that it was also mentioned there. I
> had remembered to update the model API documentation to remove the "in
> flux" warning. I'll fix that at some point.
>
> > I guess the failed assumption I was under was that table inheritance
> > would allow a single authoritative record for multiple children, and
> > thus be much more space efficient than abstract inheritance with a
> > separate copy of the parent for each child.  Given that this is not
> > the case, could I ask under which circumstances table inheritance is
> > preferable to abstract inheritance?
>
> When you are wanting to extend existing data without modifying a
> third-party table. After all, nothing says you can't just subclass a
> model with one subclass (which is common in this case). Or when you are
> frequently wanting to query the common data between a bunch of different
> child models: with table inheritance, that requires querying the parent
> table. With abstract inheritance, it requires querying every table for
> all the affected models.
>
> > I can see that a situation where one has a need to query items from a
> > single parent model, and process only parent information, would be
> > very efficient. However, processing child information given a random
> > parent is problematic with several subclasses, basically "downcasting"
> > and catching exceptions until you hit the right class, (there was a
> > discussion about the difficulties of this on irc the other day).
>
> As discussed on this list in the past, it's not possible to solve that
> without modifying the parent model (to include a type code) or having an
> external table to track the parent -> child relations for each parent
> primary key value. You could implement the latter as a third party
> product if you wanted to. We've decided in the past that it wasn't worth
> including in core, since it's an extra piece of data that can easily get
> out of sync -- particularly if your database is updated by other
> processes.
>
> Also, it just isn't the major use case for database-based inheritance
> models. If you are querying the parent table, it's because you care
> about the *common* information. So that's right there at your
> fingertips.
>
> If you frequently need to query the parent and descend to the children
> and you control the parent, you can introduce a type code or use generic
> relations (I'd personally use the former and am already doing so in a
> few bits of code I've written).
>
> > Also, accessing parent information from children is less efficient.
>
> Huh? Since it's retrieved at construction (basically a default
> select_related()) the only "inefficiency" is the code of one table join
> and if you're noticing that difference you need to start using a proper
> database. Table joins are fast at the database 

Genealogy apps

2008-04-28 Thread ecrosstexas

Does anyone know of any existing apps writtrn in Django for
genealogy?  I thought there was one in Google Code awhile back, but I
can't seem to find it now.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Great article about web2py

2008-04-28 Thread Milan Andric

This is not Django specific but it is framework relevant.  I thought
this was a great writeup of features for any framework.  At least I am
one person who likes the features of this web2py framework.

http://mdp.cti.depaul.edu/examples/static/web2py_vs_others.pdf

Web2py makes development happen faster because people can get up and
running quickly.  I have only played with it enough to be amazed.  It
allows the less technical disciplines like designers, journalists and
web producers to start building or collaborating with web based
database driven apps.

The difficulty for my organization (News21) is the biggest technical
problem which is integrating different technologies like flash and
javascript.  It is difficult to do when each discipline has their own
tools and technologies that don't integrate well. I think this is one
step closer to making these different disciplines work better.

--
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: django admin adding links to list view

2008-04-28 Thread Rajesh Dhawan

On Apr 28, 1:06 pm, Thierry <[EMAIL PROTECTED]> wrote:
> is there any way to add links to the list view in the django admin?
> I would like to links to some custom admin functionality, but it seems
> quite hard to do :)

Here's example code to add to your Model:

def my_link(self):
from django.utils.safestring import mark_safe
return mark_safe("Link title")
my_link.short_description = "Click this"
my_link.allow_tags = True

In your Admin class' list_display, add 'my_link'

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



django admin adding links to list view

2008-04-28 Thread Thierry

is there any way to add links to the list view in the django admin?
I would like to links to some custom admin functionality, but it seems
quite hard to do :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



need to refine the following query

2008-04-28 Thread [EMAIL PROTECTED]

The following query returns to me the 3 most upcoming EventDate's.  I
need to refine this query so that it will not return more than one
EventDate for a particular Event.  My query and models are shown
below.


def build_upcoming_shows(parser, tokens):
return UpcomingShowsNode()

class UpcomingShowsNode(Node):
def render(self, context):
results =
EventDate.objects.select_related(depth=1).filter(event__archive_datetime__gt
= datetime.now).order_by('datetime').distinct()[:3]
#results = Event.objects.filter(archive_datetime__gt =
datetime.now).order_by('archive_datetime').distinct()[:3]
context['upcoming_shows'] = results
return ''

register.tag('get_upcoming_shows', build_upcoming_shows)


MODELS:

class Event(models.Model):
name = models.CharField(max_length=200, help_text="Please make
sure to not use any special characters copied from a text editor in
the title.  If you need a quote or apostrophe, please type it in
manually.")
event_type = models.ForeignKey(EventType)
link = models.URLField(blank=True)
description = models.TextField(blank=True)
picture = models.ImageField(upload_to='images/', blank=True)
archive_datetime = models.DateTimeField(help_text="This is the
date the event will become archived. Date's are in -MM-DD format.
Times are given on the 24 hour clock.")
acomment = models.TextField(help_text="This is for
administrative use only and will not be displayed on the public
page.", blank=True)
class Admin:
list_display = ('name',)
search_fields = ('name',)
js = ['/media/admin/js/tiny_mce/tiny_mce.js','/media/
admin/js/tiny_mce/textareas.js']
def __str__(self):
return self.name

class EventDate(models.Model):
event = models.ForeignKey(Event, edit_inline = models.TABULAR,
num_in_admin=8, num_extra_on_change=3)
datetime = models.DateTimeField(core=True)
ordering = ['-datetime']
class Admin:
pass
def __str__(self):
return str(self.datetime)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-python-1.2.2 - install errors

2008-04-28 Thread jonknee

> I think you may want to check out this post:
>
> http://blog.awarelabs.com/?p=48
>
> Specifically, steps 4 and 5.

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



generic delete_object issue on Firefox (redirect bug)

2008-04-28 Thread yml

Hello,
I noticed a very strange behavior with the generic view called :
"delete_object". The symptom is the following :
  * Firefox return an error message
---8<---
The connection was reset

The connection to the server was reset while the page was loading.

*   The site could be temporarily unavailable or too busy. Try
again in a few
  moments.

*   If you are unable to load any pages, check your computer's
network
  connection.

*   If your computer or network is protected by a firewall or
proxy, make sure
  that Firefox is permitted to access the Web.
--->8---
It seems that the bug is in Firefox code. The same code is working
fine on IE 6.0 and Opéra, I am testing this on windows.

My code look like this (extracted form urls.py):
---8<---
 url(r'^delete/(?P[-\w]+)/$', delete_object,
{"model":Survey,
 "post_delete_redirect": "/survey/editable/",
 "template_object_name":"survey",
 "login_required": True,
 'extra_context': {'title': _('Delete survey')}
},
name='survey-delete'),
--->8---
It would be nice if someone could help me with a workaround or a
solution.

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



Re: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread James Bennett

On Mon, Apr 28, 2008 at 8:32 AM, Juanjo Conti <[EMAIL PROTECTED]> wrote:
>  Could you give me a url where new features are explained?
>  Is this backwards compatible or should I svn up with care?

Well, there's the wiki page Malcolm linked up in his original post...


-- 
"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: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread Juanjo Conti

Malcolm Tredinnick escribió:
> I merged queryset-refactor into trunk just now. This was changeset
> r7477.

Could you give me a url where new features are explained?
Is this backwards compatible or should I svn up with care?

Thanks

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

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



Re: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread hiwd


malcom,

thanks much for your hard work on this bad boy!

I've already @ioubeer ya on twitter. so the next time you're in nyc,
i'm buying.

much appreciated, cheers!



On Apr 26, 11:29 pm, Prairie Dogg <[EMAIL PROTECTED]> wrote:
> Malcom,
>
> Thanks so much for your tremendous effort and success on this!
>
> You rock!
>
> On Apr 26, 11:04 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > I merged queryset-refactor into trunk just now. This was changeset
> > r7477.
>
> > There are still a couple of enhancements to do, but I've decided they're
> > not worth holding up the entire branch for. I can just as easily do them
> > on trunk.
>
> > Thanks to everybody who reported bugs and tested things. Thanks
> > especially to Justin Bronn and Ian Kelly for lots of patches and testing
> > to get the Oracle backend up to scratch on the branch.
>
> > Detailed list of changes is in the branch's wiki page ([1]) and if
> > you're interested in seeing the documentation additions and changes, you
> > can view [2].
>
> > [1]http://code.djangoproject.com/wiki/QuerysetRefactorBranch
> > [2]http://code.djangoproject.com/changeset?new=django%2Ftrunk%2Fdocs%
> > 407477=django%2Ftrunk%2Fdocs%407411
>
> > No more bugs should now be reported against the queryset-refactor
> > version. The branch is closed.
>
> > Regards,
> > Malcolm
>
> > --
> > On the other hand, you have different 
> > fingers.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: YUI Autocomplete

2008-04-28 Thread Pigletto

> Dear all,
> I'm trying to put YUI autocomplete in my form, following this
> tutorial:http://www.djangosnippets.org/snippets/392/
I've slightly updated the snippet code but I can't check it now so if
you'll try it then let me know if something is still wrong.

--
Maciej Wisniowski
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: YUI Autocomplete

2008-04-28 Thread Pigletto

Hi!

This is my snippet, that you're using, so I hope I can help :)

> 1) Inside the my form class, if I specify:
>
> def __init__(self,*args, **kwargs ):
> super(QuizForm, self).__init__(*args,
> **kwargs)
> n_lookup_url = reverse('djangoOp.op.views.json_lookup')  # url to your
> view
> n_schema = '["resultset.results",
> "tag", ]'
> forms.fields['tags'].widget = AutoCompleteWidget()
> forms.fields['tags'].widget.lookup_url = n_lookup_url
> forms.fields['tags'].widget.schema = n_schema
>
> I receive:
>
> unsubscriptable object
> on line:
> forms.fields['tags'].widget = AutoCompleteWidget()
If you're writting this in form's __init__ method then use:
self.fields['tags'].widget = AutoCompleteWidget()
self.fields['tags'].widget.lookup_url = n_lookup_url
self.fields['tags'].widget.schema = n_schema

--
Maciej Wisniowski
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django have unique user homepage?

2008-04-28 Thread jmDesktop

Does anyone have a recommendation on which implementation to use when
creating a self-authentication system?  There weren't that many, but
thought some of you might have experience with one.

On Apr 26, 6:01 pm, Bret W <[EMAIL PROTECTED]> wrote:
> And that's just one way, of course.
>
> On Apr 26, 5:01 pm, Bret W <[EMAIL PROTECTED]> wrote:
>
> > Sure.
>
> > You'd need to create a profile model where this information could be
> > stored.http://www.djangoproject.com/documentation/authentication/#storing-ad...
>
> > You'd then just create forms for inputing the parameters you wanted to
> > let users 
> > control.http://www.djangoproject.com/documentation/newforms/#generating-forms...
>
> > After you've allowed users to input preferences in their profile,
> > you'd just need to get the profile (see Django book), and use the
> > stored parameters in your template.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Looking at objects by year, month

2008-04-28 Thread Darryl Ross

Ryan Vanasse wrote:

Trying to get the outer for loop working is something that I don't
really understand. I think that what I have now isn't going to work
because I'm using a dictionary reference on what was transmuted into
the Context, so that "eventsByMonth" doesn't exist...


I've been trying to work out if it would be possible to do this using 
the ORM to order the events by month, ignoring the day and year, and 
then the regroup tag in the template, but I can't get it to work in the 
shell. The issue is the ORM (even post-qsrf) doesn't seem to like 
.order_by('day__month'). It is possible to do at the SQL level, eg, 
using DATE_PART for PostgreSQL, but I don't know what support in the 
different databases is like.


Anyway, one way I came up with to do it, which works but isn't 
particularly "pretty", would be something like:


  def UpcomingEvents(request)
  months = { 1:  {'name': 'January',   'events': []},
 2:  {'name': 'February',  'events': []},
 3:  {'name': 'March', 'events': []},
 4:  {'name': 'April', 'events': []},
 5:  {'name': 'May',   'events': []},
 6:  {'name': 'June',  'events': []},
 7:  {'name': 'July',  'events': []},
 8:  {'name': 'August','events': []},
 9:  {'name': 'September', 'events': []},
 10: {'name': 'October',   'events': []},
 11: {'name': 'November',  'events': []},
 12: {'name': 'December',  'events': []}
   }
  for event in Event.objects.order_by('start_DateTime'):
  events[event.start_DateTime.month]['events'].append(event)
  return render_to_response('calendar.html', {'months': months})

Assuming you want the events under each month to be ordered 
chronologically, then the order_by('start_DateTime') is still important. 
Then in the template you should be able to do something like:


   {% for month in months %}
{{month.name}}

   {% for event in month.events %}
{{event.eventName}}
   {% endfor %}

   {% endfor %}

Hope that gives you a pointer.

Cheers
Darryl



signature.asc
Description: OpenPGP digital signature


Re: MySQL-python-1.2.2 - install errors

2008-04-28 Thread [EMAIL PROTECTED]

I think you may want to check out this post:

http://blog.awarelabs.com/?p=48

Specifically, steps 4 and 5.

Disclaimer, I have not personally installed or used mysql in years.  I
just happened to come across both these posts today.

Hope That Helps,
-Thomas


On Apr 27, 9:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Can anyone help me with these errors:
>
> python setup.py buildrunning build
> running build_py
> copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
> running build_ext
> building '_mysql' extension
> gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
> madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -
> DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -
> Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql/
> include -I/System/Library/Frameworks/Python.framework/Versions/2.5/
> include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/
> _mysql.o -Os -arch i386 -fno-common
> In file included from /usr/local/mysql/include/mysql.h:47,
>  from _mysql.c:40:
> /usr/include/sys/types.h:92: error: duplicate ‘unsigned’
> /usr/include/sys/types.h:92: error: two or more data types in
> declaration specifiers
> error: command 'gcc' failed with exit status 1
>
> Thanks,
>
> Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Performance Discoveries Part 1

2008-04-28 Thread Graham Dumpleton

On Apr 28, 5:44 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Christian Vest Hansen napisał(a):
>
> > On 4/28/08, rich <[EMAIL PROTECTED]> wrote:
> >>  Yes, I too am at a similar level of confusion as to when django is not
> >>  thread safe.
>
> > With the python GIL, is it even possible to create a python program
> > that isn't thread-safe? I thought that was the whole point of having a
> > GIL in the first place; make concurrency a non-issue.
>
> Yes, it is still possible. Create an object with global state, alter it
> from different threads without locking and there you go, the state of
> object is not consistent (threads can not rely on the state), you might
> even get race condition. GIL protects only internal state of VM, not
> your objects' state.

Correct. For some background on when multithreading issues apply with
mod_wsgi, see:

  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

In particular, for any configuration where wsgi.multithread is True,
you need to know your code is thread safe.

The document includes a brief summary at the end about building
portable applications that can deal with both multithread and
multiprocess web servers.

Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Grrr, can't import custom template tag

2008-04-28 Thread Jay

Hi!  Yes, in fact on the development server it works fine.  On the
production server I'm using lighttpd/fcgi, and I have stopped and
restarted both approximately 800 times.  It's very strange.  I feel
like it must be something to do with my server configuration.  I have
the exact same versions of django/satchmo on both dev & production.

I was temporarily able to get it to import the tag by dropping it into
django/templatetags, but I don't like that solution as I will likely
forget and overwrite that directory the next time I update django.

On Apr 28, 4:13 am, David Reynolds <[EMAIL PROTECTED]>
wrote:
> On 28 Apr 2008, at 1:35 am, Jay wrote:
>
> > And I think that's it.  This is really driving me crazy.  Is there
> > anything I'm forgetting?  Anything obvious?  I would be extremely
> > grateful if someone could give this a once-over and let me know what
> > I'm missing.
>
> If you're running on Apache, have you restarted it? Have you stopped  
> and started your development server?
>
> --
> David Reynolds
> [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
-~--~~~~--~~--~--~---



YUI Autocomplete

2008-04-28 Thread Orazio

Dear all,
I'm trying to put YUI autocomplete in my form, following this
tutorial: http://www.djangosnippets.org/snippets/392/

There are two main problems:

1) Inside the my form class, if I specify:

def __init__(self,*args, **kwargs ):
super(QuizForm, self).__init__(*args,
**kwargs)
n_lookup_url = reverse('djangoOp.op.views.json_lookup')  # url to your
view
n_schema = '["resultset.results",
"tag", ]'
forms.fields['tags'].widget = AutoCompleteWidget()
forms.fields['tags'].widget.lookup_url = n_lookup_url
forms.fields['tags'].widget.schema = n_schema

I receive:

unsubscriptable object
on line:
forms.fields['tags'].widget = AutoCompleteWidget()

2) I overcome the last problem through AutoCompleteWidget __init__
function.
Unfortunately I receive another, more serious, error:

'AutoCompleteWidget' object has no attribute 'attrs'

Do I make some terrible mistakes or tutorial miss some information ?

I think Autocomplete and other ajax stuff could improve a lot the
whole Django project, but right now I feel the integration too much
complicated! Is it just my impression?

Lorenzo




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



Re: newforms extensions

2008-04-28 Thread Dominik Szopa



On 26 Kwi, 13:42, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> We have developed a few extensions to newforms library, and published
> it for public
> use. It is more just a simple snippet, so I decided to have a SVN
> repository and publish
> it on our website.
>
> I've started writing documentation (please tell me if its good enough
> to start ?):
>
> http://public.halogen-dg.com/wiki/newforms_py
>
> What it does, shortly:
>  - vertical layout for form (so you can edit a few recods of same type
> in a single form)
>  - child-forms (so you can embed a form in a single field with JS
> popup)
>
> Regards,
>   Alex V. Koval

It looks very cool. I have tried your examples, and i have javascript
error when i try to add or remove a row.

"getElement is not defined"

should be there "getElementByID" instead of "getElement" ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Looking at objects by year, month

2008-04-28 Thread Ryan Vanasse

Hello.

Thank you for your helpfulness and friendliness on this group. I have
found it very helpful in getting me past some of the rough spots in
starting out with django.

I'm creating a calendar of events. I want to show an entire year's
worth of events, but group them on the page into months. For an
example (but only for three months, not an entire year), see "http://
rdvanasse.nwc.edu/theremnant/calendar/index.html".

I have two questions with this. The first regards my view. Naturally,
I would wish to take advantage of the archive_year generic view,
however, I cannot see how this would allow for grouping by month on
the page. Is this possible?


Currently, my view looks something like this:

def upcomingEvents(request):
janEvents = Event.objects.filter(start_DateTime__month = 1)
   ...repeat for each month...

   eventsByMonth = {'january':janEvents, [repeat for month] }

   return render_to_response('calendar.html', eventsByMonth)

Is this the only way to handle something like this?

Secondly, in my template, I want to reproduce my month grouping div
for each month, and within each month, I want to create a new table
row for the events in that month.
Right now, I have something like this:
{% for month in eventsByMonth.values %}




{% for Event in month %}





{{Event.eventName}} {{Event.eventDetails|truncatewords:"8"}}


{% endfor %}



{% endfor %}

Earlier I had hardcoded each month into my template and made it {% for
Event in january %} (for example). This worked fine.

Trying to get the outer for loop working is something that I don't
really understand. I think that what I have now isn't going to work
because I'm using a dictionary reference on what was transmuted into
the Context, so that "eventsByMonth" doesn't exist...

But then is there a way to iterate through all dictionary references
in the entire context you've passed the template? That's what I think
would satisfy my requirements.

a final thought on that...say I did get that going...would there be a
way to insert the key (i.e. 'january'...see the eventsByMonth in my
view above) in the image source where I presently have {{ month }}?

I'm sorry for thinking about things in such convoluted ways. I'm
trying to keep things simpler, but it is a learning process. Thanks
for your time.

Ryan Vanasse


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



Re: Queryset-refactor branch has been merged into trunk

2008-04-28 Thread Matt Hoskins



On Apr 27, 4:04 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> I merged queryset-refactor into trunk just now. This was changeset
> r7477.

Thanks for all your hard work Malcolm on queryset-refactor, it's much
appreciated!

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



Re: Grrr, can't import custom template tag

2008-04-28 Thread David Reynolds


On 28 Apr 2008, at 1:35 am, Jay wrote:

> And I think that's it.  This is really driving me crazy.  Is there
> anything I'm forgetting?  Anything obvious?  I would be extremely
> grateful if someone could give this a once-over and let me know what
> I'm missing.

If you're running on Apache, have you restarted it? Have you stopped  
and started your development server?

-- 
David Reynolds
[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 Performance Discoveries Part 1

2008-04-28 Thread Jarek Zgoda

Christian Vest Hansen napisał(a):

> On 4/28/08, rich <[EMAIL PROTECTED]> wrote:
>>  Yes, I too am at a similar level of confusion as to when django is not
>>  thread safe.
> 
> With the python GIL, is it even possible to create a python program
> that isn't thread-safe? I thought that was the whole point of having a
> GIL in the first place; make concurrency a non-issue.

Yes, it is still possible. Create an object with global state, alter it
from different threads without locking and there you go, the state of
object is not consistent (threads can not rely on the state), you might
even get race condition. GIL protects only internal state of VM, not
your objects' state.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sort QuerySet

2008-04-28 Thread Amit Ramon

* Malcolm Tredinnick <[EMAIL PROTECTED]> [2008-04-28 16:17 +1000]:
> 
> 
> On Sun, 2008-04-27 at 23:03 -0700, Poz wrote:
> [...]
> > I'm going crazy with this problem. Anyone know how to sort a QuerySet
> > with an attribute that's not part of the database?? Transform it into
> > l list?
> 
> Precisely. Since you can't do the sorting at the database level, you
> have to sort at the Python level. Which means giving the sort function
> access to all the data (it's possible to write a sorting function that
> produces sorted output as the results are pulled from an iterator, but
> it's performance isn't great).
> 
> Sort convert your data to a list and then use list sorting. You'll need
> to pass in the "key" attribute in Python 2.5, or pass in a cmp function
> in all versions of Python, but at that point it's simply normal list
> sorting.
> 
> Regards,
> Malcolm
> 
> -- 
> What if there were no hypothetical questions? 
> http://www.pointy-stick.com/blog/
> 

I think it might be possible to achieve that using QuerySet's extra() method. 
It might depend on the specific details, but if you can write a SQL that 
computes the score for a movie, you can add it to the selected columns and 
order by it. I'm doing something similar and it's working well.

It goes along the following lines:

# write a SQL select statement that calculate the score for a given movie:
score_sql = ". "
# use extra() to add a column to the selected columns, and order by it:
movies_queryset = Movie.objects.extra(select={'score': 
score_select}).order_by('score')

Note that there is a ticket for a bug when a select in extra has parameters
 (i.e. extra(select={...}, params=[...]), so be aware of that (you don't have 
to use params).

If you can do it that way, it may be better than using a python list. The 
performance of doing it in the database might be better, and besides, you 
cannot always pass python lists to some generic views instead of query sets. 
E.g., object_list cannot take a list.

Hope this helps,

Amit






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Performance Discoveries Part 1

2008-04-28 Thread Christian Vest Hansen

On 4/28/08, rich <[EMAIL PROTECTED]> wrote:
>
>  Yes, I too am at a similar level of confusion as to when django is not
>  thread safe.

With the python GIL, is it even possible to create a python program
that isn't thread-safe? I thought that was the whole point of having a
GIL in the first place; make concurrency a non-issue.

But maybe mod_wsgi throws that assumption out the door. I wouldn't
know about that.

>
>  I assume this could happen only if I explicitly create new threads
>  myself, or if I use some non-django module that isn't itself thread
>  safe.
>
>  Would be fantastic if someone could clarify this!
>
>  many thanks
>
>  Richard
>
>
>
>  On Apr 27, 11:08 pm, Prairie Dogg <[EMAIL PROTECTED]> wrote:
>  > I'm still trying to wrap my head around what the advantages of
>  > worker MPM are, I've read a couple articles that have started me
>  > down this road - the consensus view seems to be worker MPM
>  > w/ mod_wsgi is the best way to go from a memory and separtion
>  > of concerns POV, the only potential drawback being that your
>  > django app needs to be 'thread safe'.  Sadly I'm too much of
>  > a novice to really understand what that means in terms of my
>  > code or what sorts of patterns I should be using or avoiding.
>  >
>  > On Apr 27, 7:17 am, rich <[EMAIL PROTECTED]> wrote:
>  >
>  > > Thanks for sharing!
>  >
>  > > My setup is similar to yours except I don't use nginx at all - just
>  > > another apache virtual host for media.mysite.com. Not sure which is
>  > > best, but one less moving part from my point of view?
>  >
>  > > I haven't done any load testing, but I really like the way mod_wsgi
>  > > works; I use it in daemon mode (with worker MPM Apache) - it's never
>  > > caused me a problem and **feels** tidier than fcgi.
>  >
>  > > Also I have much less memcached - only 16MB, but I'm on a 256Mb
>  > > slicehost slice, for now; I haven't explored any optimisations here as
>  > > I'm still building core features in my first django project.
>  >
>  > > I've had one drama where Gutsy crashed: out of memory, unfortunately I
>  > > didn't realise until all log evidence fell off the end of the syslog
>  > > cliff.
>  >
>  > > Happy optimising
>  > > Rich
>  >
>  > > On Apr 27, 3:16 pm, Prairie Dogg <[EMAIL PROTECTED]> wrote:
>  >
>  > > > Hey Everybody,
>  >
>  > > > I've been using django for almost a year now and I've been spending
>  > > > some time recently trying to optimize the slicehost VPS(s) that I use
>  > > > to run several django sites I've developed.  I wanted to share my
>  > > > findings with the larger group in hopes that my oversights can be
>  > > > pointed out and whatever 'findings' I've made can be useful to folks
>  > > > who are just starting off.  I've been developing a blow-by-blow of my
>  > > > slicehost setup - I gained a lot from the "dreamier django dream
>  > > > server" blog post a while back.  But to make things brief for the
>  > > > first post, I'll just summarize my setup here:
>  >
>  > > > 512 meg slicehost slice w/ Hardy Heron
>  > > > memcached with cmemcached bindings doin' its cache thang with 256 megs
>  > > > of RAM
>  > > > nginx on port 80 serving static files
>  > > > apache mpm worker on 8080 w / mod_wsgi serving dynamic content
>  > > > postgres 8.3 w/ geo libraries
>  > > > django_gis (thanks justin!)
>  > > > my application
>  >
>  > > > I'll keep it to 3 sections of musings for this post:
>  >
>  > > > triage troubles
>  > > > memcached musings
>  > > > context-processor conundrum
>  >
>  > > > triage troubles
>  >
>  > > > At pycon someone asked Jacob KM what he used to performance test his
>  > > > websites and he said "siege".  A quick google search turned it up
>  > > > (http://www.joedog.org/JoeDog/Siege).
>  > > > I seem to recall Jacob mentioning that this was his preferred method
>  > > > because it was more of a "real life" test than perhaps benchmarking
>  > > > tools that would profile the code.  Compiling and using siege was a
>  > > > snap.  My test was of a site I wrote that does a lot of database
>  > > > queries to draw up any given page (mostly because of a complex
>  > > > sidebar) when I turned it on, real easy like, to a dev server, the
>  > > > server crumbled with only 10 simultaneous users and anything higher
>  > > > than 5 clicks per user.
>  >
>  > > > Observation #1: Make sure your debug settings are turned off.
>  >
>  > > > After I turned debug settings off, performance maybe doubled, but
>  > > > still was nothing that could handle even moderate traffic gracefully.
>  > > > 20 simultaneous users on 3 clicks per user were getting up into the
>  > > > 20+ second wait for a response range. Basically awful.  Not shocked,
>  > > > because I knew that my db querying was horrendously inefficient.  This
>  > > > was OK, because I had memcached up my sleeve.  An observation that I
>  > > > made on the first test that was constant throughout all subsequent
>  > > > tests, was that initial queries were the 

Re: [Django Code] #7101: ordering ForeignKey(self) =FieldError: Infinite loop caused by ordering.

2008-04-28 Thread Carl Karsten

Malcolm Tredinnick wrote:
> 
> On Sun, 2008-04-27 at 23:19 -0500, Carl Karsten wrote:
> [...]
>> order_by('parent_id') doesn't do anything for the Admin UI, which is where I 
>> 'need' this. 
> 
> I made a typo. It should be 'parent__id' there (double underscore).
> You're manually telling Django to order by one level, using the parent's
> primary key.

Bingo.

And this does the trick:

 class Meta:
 ordering = ('parent__id', 'order',)


Thanks,

Carl K

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



Re: Sort QuerySet

2008-04-28 Thread Malcolm Tredinnick


On Sun, 2008-04-27 at 23:03 -0700, Poz wrote:
[...]
> I'm going crazy with this problem. Anyone know how to sort a QuerySet
> with an attribute that's not part of the database?? Transform it into
> l list?

Precisely. Since you can't do the sorting at the database level, you
have to sort at the Python level. Which means giving the sort function
access to all the data (it's possible to write a sorting function that
produces sorted output as the results are pulled from an iterator, but
it's performance isn't great).

Sort convert your data to a list and then use list sorting. You'll need
to pass in the "key" attribute in Python 2.5, or pass in a cmp function
in all versions of Python, but at that point it's simply normal list
sorting.

Regards,
Malcolm

-- 
What if there were no hypothetical questions? 
http://www.pointy-stick.com/blog/


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



Sort QuerySet

2008-04-28 Thread Poz

Okay I'm gone crazy over the last couple days trying to figure this
out.

I'm creating a movie ranking application. To show the movies I create
a QuerySet with all the movies in the "group" the users is looking at.
Then I pull all the votes that group has given to that movie and get
the average. I give each movie in the movie set a new attribute name
score. I now want to sort that QuerySet with the new 'score' attribute
that i've calculated.

I've tried the movies.sort('score') and movies.order_by('score')
neither work.

I'm going crazy with this problem. Anyone know how to sort a QuerySet
with an attribute that's not part of the database?? Transform it into
l list? Is there a different sort function?

If you're interested here's my code I'm using:

Thanks,
Poz


def event(request, event_id):
try:
e = Event.objects.get(id__exact=event_id)
except Event.DoesNotExist:
raise Http404
movies = e.movies.all()  < HERE'S
WHERE THE QUERYSET IS CREATED
user = request.user
for movie in movies:
votes = Vote.objects.filter(event=e, movie=movie)
totalscore = 0
totalvoters = 0
for vote in votes:
totalscore += vote.score
totalvoters += 1
if totalscore == 0:
movie.score = 0
else:
movie.score = float(totalscore) / totalvoters
< HERE'S WHERE I ADD THE SCORE
ATTRIBUTE TO THE QUERYSET
movie.totalscore = totalscore
movie.totalvoters = totalvoters
if Vote.objects.filter(event=e, user=user, movie=movie):
uservote = Vote.objects.get(event=e, user=user,
movie=movie)
movie.uservote = uservote.score
else:
movie.uservote = 0
votes = Vote.objects.filter(event=e, user=user)
form = MovieForm()
movies = movies.order_by('sort') <
HERE'S WHERE I WANT TO SORT THE QUERYSET
return render_to_response('event.html', {'event': e, 'movies':
movies, 'user': user, 'score': totalscore, 'form': form,
'searchresults': searchresults})


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---