Filtering does not work through recursive models

2009-02-01 Thread James Pearce

(or so it seems)

My model has a class with a reference to itself. It's for modelling a
hierarchy of geographical areas. (e.g. cities in states, states in
countries, countries in continents etc)

class Area(models.Model):
  name  = models.CharField(max_length=50)
  parent= ForeignKey('self', blank=True, null=True)
  ...

This all works fine.

Now, in the admin interface, a search_field looks for parents matching
a phrase:

  search_fields = {'area': (['^parent__name'])}

This also works fine. The (paraphrased) SQL generated is:

  SELECT ... FROM `area` INNER JOIN `area` T2 ON (`area`.`parent_id` =
T2.`id`) WHERE (T2.`name` LIKE phrase% )

Super!

Now... I'd like a similar search for *grandparents* matching a phrase:

  search_fields = {'area': (['^parent__parent__name'])}

Hm... doesn't seem to work. Only returns those with matching
*parents*. And the SQL is:

  SELECT ... FROM `area` INNER JOIN `area` T2 ON (`area`.`parent_id` =
T2.`id`) INNER JOIN `area` T3 ON (`area`.`parent_id` = T3.`id`) WHERE
(T3.`name` LIKE phrase% )

Now I think that second inner join condition should be (T2.`parent_id`
= T3.`id`) because it's the parent of the parent... no?

It seems Django is getting confused because it's querying through the
same model class, but isn't paying attention to recursed instances.

This is Django 1.0.2. Any clues? Is there some (even more) magic query
syntax I should use? Is this a dumb newbie question? ;-)

Many thanks
James

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



Re: Admin get_urls

2009-02-01 Thread Dave Fowler

Daniel, thanks for the response

I'm on the latest svn version

d...@django$ svn up
At revision 9803.

so my version shouldn't be the issue.


On Feb 2, 1:44 am, Daniel Roseman 
wrote:
> On Feb 1, 10:11 pm, Dave Fowler  wrote:
>
>
>
> > I'm adding new views to my admin models.  The documentation is 
> > here:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#get-urls-self
>
> > and the following is my implementation ( I think the same thing )
>
> > from django.conf.urls.defaults import *
>
> > class AisleAdmin(admin.ModelAdmin):
> >     def get_urls(self):
> >         urls = super(AisleAdmin, self).get_urls()
> >         my_urls = patterns('',
> >             (r'^reorders/$', 'path.to.view', )
> >         )
> >         return my_urls + urls
>
> > The base url for the Aisle admin is /grocery/aisle/    so I assume
> > that my new view would be at /grocery/aisle/reorders/
>
> > Its not however, I instead get this:   invalid literal for int() with
> > base 10: 'reorders'
>
> > I put prints inside the get_urls function to see if its getting there,
> > and it isn't.  I'm on the latest svn version.
>
> > What am I missing?  Any help would be great.
>
> I believe that functionality is only available on the development
> version of Django. Are you running a checkout after version 1.02, or
> the released version?
>
> For some reason the 'new in development version' tag is missing from
> the documentation you link to there.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "invalid reference to FROM-clause" for nested annotate query

2009-02-01 Thread omat

I just remembered that the above error occured when running on
Postgresql 8.2. Sorry for the misinformation about SQLite.

Then to give it a try with SQLite, I built a fresh database with
syncdb on SQLite.

This time, at the same point, I get a:

OperationalError: no such column: tagging_taggeditem.added


This is very strange, because the column 'added' is surely there.




On Feb 1, 11:39 pm, omat  wrote:
> Hi,
>
> TaggedItem model is as follows:
>
> class TaggedItem(models.Model):
>     tag = models.ForeignKey(Tag, verbose_name=_('tag'),
> related_name='items')
>     added = models.DateTimeField(auto_now_add=True)
>     content_type = models.ForeignKey(ContentType, verbose_name=_
> ('content type'))
>     object_id = models.PositiveIntegerField(_('object id'),
> db_index=True)
>     object = generic.GenericForeignKey('content_type', 'object_id')
>
> And I am using sqlite on Mac OS X with django revison 9781.
>
> Thanks,oMat
>
> On Feb 1, 1:12 am, Russell Keith-Magee  wrote:
>
> > On Sun, Feb 1, 2009 at 12:44 AM,omat wrote:
>
> > > Hi all,
>
> > > I obtain a list of tag ids by:
> > > tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max
> > > ('added'))[:10]
>
> > > and try to use it in the following query to obtain tag objects:
> > > Tag.objects.filter(id__in=tag_ids)
>
> > > But i get "invalid reference to FROM-clause" error:
>
> > > Caught an exception while rendering: invalid reference to FROM-clause
> > > entry for table "tagging_taggeditem"
> > > LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX
> > > ("tagging_t...
> > >                                                             ^
> > > HINT:  Perhaps you meant to reference the table alias "u0".
>
> > > If I force the first query to be evaluated, using the step syntax (ie
> > > [:10:1] instead of [:10]), then everthing works fine.
>
> > > Seems like a bug?
>
> > I'm not seeing this failure on SQLite, Postgres or MySQL. However, I
> > was testing using my own test models, not your models - it's possible
> > that the problem could be caused by the interaction of some other
> > property of your model on the aggregate query.
>
> > Can you provide the full definition of the TaggedItem model you are
> > using? It would also be helpful to know the database version and
> > operating system you are using.
>
> > Yours,
> > Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin get_urls

2009-02-01 Thread Daniel Roseman

On Feb 1, 10:11 pm, Dave Fowler  wrote:
> I'm adding new views to my admin models.  The documentation is 
> here:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#get-urls-self
>
> and the following is my implementation ( I think the same thing )
>
> from django.conf.urls.defaults import *
>
> class AisleAdmin(admin.ModelAdmin):
>     def get_urls(self):
>         urls = super(AisleAdmin, self).get_urls()
>         my_urls = patterns('',
>             (r'^reorders/$', 'path.to.view', )
>         )
>         return my_urls + urls
>
> The base url for the Aisle admin is /grocery/aisle/    so I assume
> that my new view would be at /grocery/aisle/reorders/
>
> Its not however, I instead get this:   invalid literal for int() with
> base 10: 'reorders'
>
> I put prints inside the get_urls function to see if its getting there,
> and it isn't.  I'm on the latest svn version.
>
> What am I missing?  Any help would be great.

I believe that functionality is only available on the development
version of Django. Are you running a checkout after version 1.02, or
the released version?

For some reason the 'new in development version' tag is missing from
the documentation you link to there.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django-gitosis

2009-02-01 Thread Jeff Anderson

Hello fellow Django users!

I've been wanting to set up gitosis on a server for a while now. I think 
a new Django app might make this easier for the end users. The people 
that'd access the git repos I want to host could simply put their public 
SSH key in their Django-powered user profile, the new app lets gitosis 
know, and away they go.

The only issue is that gitosis expects me to build configuration files 
manually, adding users by hand. It'd be fairly straightforward to get a 
django-gitosis app to streamline this for me. I'm mostly interested in 
getting feedback for my ideas. If someone is interested, and would like 
to contribute to my little app, that'd be great too.

I haven't dove into the gitosis code much, but it is written in Python. 
At some point gitosis parses the config options and makes them available 
via a Python interface. The first way to get a django-gitosis to handle 
the configuration on the fly would be to replace the code that parses 
the text file, and make it code that parses a Django model, but returns 
the same type of information to the file. I bet this method is more 
trouble than it's worth.

The next method is to modify the config files directly. I like this 
solution better because it's the simplest one. Simple usually means 
"less likely to break in the future", which is good. I do believe that 
gitosis uses a Python module to read from and write to its config files, 
and I can use the same thing.

What method would you use, and why?

Thanks for the input!



Jeff Anderson

gitosis: |git://eagain.net/gitosis.git|


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



Re: Django newbie question re: porting from Google App Engine to Django standalone

2009-02-01 Thread Rama Vadakattu

Please have a look at the below link:
http://code.google.com/appengine/articles/pure_django.html

May be it helps you in porting the app from appengine to django.

--rama
On Feb 1, 5:16 am, "Mark.Petrovic"  wrote:
> Good day.  I'm new here, as well as a new (all of two months of
> experience) Python web app developer.
>
> I'm interested in porting a Google App Engine
> "google.appengine.ext.webapp"-based app to a standalone Django app on
> another platform.  I've ported my data models from GAE to Django, as
> well as my data access objects.  And I can see from here what I would
> need to do to port my url routes currently expressed through
>
> application = webapp.WSGIApplication([('/admin/account/register',
> admincontroller.AdminRegisterController),], debug=True)
>
> to a set of routes in the Django urls.py file.  (Aside:  could I
> actually keep the WSGIApplication router, too?!  If yes, how?)
>
> What I am interested in now is preserving as much line by line code in
> my various controllers (e.g.,
> admincontroller.AdminRegisterController).  I'm less concerned about
> building http response objects by hand in Django as I am about the
> function vs. class routing disparity between Django and GAE webapp-
> based routing.  As I read the Django book by Holovaty, et al., the
> urls.py routes take a regex url path and maps it to a function.
> Whereas the the GAE routing maps a regex url path to a class that
> implements handlers for GET, POST, etc.
>
> Since I'm new at all this, I did not have the foresight to build in
> any abstraction as a hedge against a future port.  The app isn't that
> large, though, so porting it brute force to use functions instead of
> classes in the routing table is not that big a deal.
>
> Can anyone talk about how I get there from here re the routing
> semantic disparity?
>
> Thank you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread Will Matos
The problem is that the iframe is part of the main page. When the main page is 
refreshed, the iframe goes with it. Unless you have the form in a separate 
iframe the behavior will continue to be the same. 

W


- Original Message -
From: django-users@googlegroups.com 
To: Django users 
Sent: Sun Feb 01 21:07:28 2009
Subject: Re: trouble with Django and javascript


Not working. Still the same problem( when button is clicked, the text
of "This is a test" will display in the iframe for one second, and
then disappear.).

On Feb 2, 12:55 pm, "Will Matos"  wrote:
> Onclick="test();submit();"
> Will Matos
> TCDI
> Dir. of Tech. Sales
>
>
>
> - Original Message -
> From: django-users@googlegroups.com 
> To: Django users 
> Sent: Sun Feb 01 20:54:32 2009
> Subject: Re: trouble with Django and javascript
>
> If I use Onclick="submit();", how to add the javascript function " test
> ()" to that buttom?
>
> thanks
>
> On Feb 2, 11:58 am, "Will Matos"  wrote:
> > Onclick="submit();"
> > Will Matos
> > TCDI
> > Director of Technical Sales
> > 4510 Weybridge Lane
> > Greensboro, NC  27407
> > 336.232.5832 office
> > 336.232.5850 fax
> > 336.414.0467 mobile  
>
> > - Original Message -
> > From: django-users@googlegroups.com 
> > To: Django users 
> > Sent: Sun Feb 01 19:52:49 2009
> > Subject: Re: trouble with Django and javascript
>
> > Thanks for you reply.
>
> > However, if I change the 'submit' to button, how can I submit the form
> > to the server?
>
> > Regards
> > min
>
> > On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> > > In addition to displaying the message, it's also submitting the form,
> > > so you see the text for a second and then the form reloads.
>
> > > Change the  instead of "submit" and see if that 
> > > helps.
>
> > > Todd
>
> > > On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > > > First I  have a form:
>
> > > > class TestForm(forms.Form):
> > > >  name = forms.CharField( max_length=30 )
> > > >  age = forms.CharField( max_length=30 )
>
> > > > Then in the views.py:
>
> > > > def Test_page(request):
>
> > > >  form = TestForm()
> > > >  variables = RequestContext(request, {
> > > >    'form': form,
> > > >  })
> > > >  return render_to_response('Test.html', variables)
>
> > > > In the temlates file, I want to add a iframe and a submit button. When
> > > > the submit button was clicked, some word will appear in the iframe.
> > > > The following code is the Test.html:
>
> > > > 
> > > > Test Result Page
> > > > 
> > > >      
> > > >              function test(){
> > > >                              var iframe = document.getElementById
> > > > ("test");
> > > >                              var d = iframe.contentDocument;
> > > >                              d.body.innerHTML = "This is a test";
> > > >                              }
> > > >      
> > > > 
> > > > 
> > > >   
> > > >        Name:{{form.name}}
> > > >        age: {{form.age}}
> > > >        
> > > >        
> > > >   
> > > > 
> > > > 
>
> > > > Now, the problem is that, when I clicked the submit button, the text
> > > > of "This is a test" will display in the iframe for one second, and
> > > > then disappear. Is there any one know what's wrong with my code?
>
> > > > thanks
> > > > min


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



Re: trouble with Django and javascript

2009-02-01 Thread min

Not working. Still the same problem( when button is clicked, the text
of "This is a test" will display in the iframe for one second, and
then disappear.).

On Feb 2, 12:55 pm, "Will Matos"  wrote:
> Onclick="test();submit();"
> Will Matos
> TCDI
> Dir. of Tech. Sales
>
>
>
> - Original Message -
> From: django-users@googlegroups.com 
> To: Django users 
> Sent: Sun Feb 01 20:54:32 2009
> Subject: Re: trouble with Django and javascript
>
> If I use Onclick="submit();", how to add the javascript function " test
> ()" to that buttom?
>
> thanks
>
> On Feb 2, 11:58 am, "Will Matos"  wrote:
> > Onclick="submit();"
> > Will Matos
> > TCDI
> > Director of Technical Sales
> > 4510 Weybridge Lane
> > Greensboro, NC  27407
> > 336.232.5832 office
> > 336.232.5850 fax
> > 336.414.0467 mobile  
>
> > - Original Message -
> > From: django-users@googlegroups.com 
> > To: Django users 
> > Sent: Sun Feb 01 19:52:49 2009
> > Subject: Re: trouble with Django and javascript
>
> > Thanks for you reply.
>
> > However, if I change the 'submit' to button, how can I submit the form
> > to the server?
>
> > Regards
> > min
>
> > On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> > > In addition to displaying the message, it's also submitting the form,
> > > so you see the text for a second and then the form reloads.
>
> > > Change the  instead of "submit" and see if that 
> > > helps.
>
> > > Todd
>
> > > On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > > > First I  have a form:
>
> > > > class TestForm(forms.Form):
> > > >  name = forms.CharField( max_length=30 )
> > > >  age = forms.CharField( max_length=30 )
>
> > > > Then in the views.py:
>
> > > > def Test_page(request):
>
> > > >  form = TestForm()
> > > >  variables = RequestContext(request, {
> > > >    'form': form,
> > > >  })
> > > >  return render_to_response('Test.html', variables)
>
> > > > In the temlates file, I want to add a iframe and a submit button. When
> > > > the submit button was clicked, some word will appear in the iframe.
> > > > The following code is the Test.html:
>
> > > > 
> > > > Test Result Page
> > > > 
> > > >      
> > > >              function test(){
> > > >                              var iframe = document.getElementById
> > > > ("test");
> > > >                              var d = iframe.contentDocument;
> > > >                              d.body.innerHTML = "This is a test";
> > > >                              }
> > > >      
> > > > 
> > > > 
> > > >   
> > > >        Name:{{form.name}}
> > > >        age: {{form.age}}
> > > >        
> > > >        
> > > >   
> > > > 
> > > > 
>
> > > > Now, the problem is that, when I clicked the submit button, the text
> > > > of "This is a test" will display in the iframe for one second, and
> > > > then disappear. Is there any one know what's wrong with my code?
>
> > > > thanks
> > > > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread Will Matos
Onclick="test();submit();"
Will Matos
TCDI
Dir. of Tech. Sales

- Original Message -
From: django-users@googlegroups.com 
To: Django users 
Sent: Sun Feb 01 20:54:32 2009
Subject: Re: trouble with Django and javascript


If I use Onclick="submit();", how to add the javascript function " test
()" to that buttom?

thanks

On Feb 2, 11:58 am, "Will Matos"  wrote:
> Onclick="submit();"
> Will Matos
> TCDI
> Director of Technical Sales
> 4510 Weybridge Lane
> Greensboro, NC  27407
> 336.232.5832 office
> 336.232.5850 fax
> 336.414.0467 mobile  
>
>
>
> - Original Message -
> From: django-users@googlegroups.com 
> To: Django users 
> Sent: Sun Feb 01 19:52:49 2009
> Subject: Re: trouble with Django and javascript
>
> Thanks for you reply.
>
> However, if I change the 'submit' to button, how can I submit the form
> to the server?
>
> Regards
> min
>
> On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> > In addition to displaying the message, it's also submitting the form,
> > so you see the text for a second and then the form reloads.
>
> > Change the  instead of "submit" and see if that 
> > helps.
>
> > Todd
>
> > On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > > First I  have a form:
>
> > > class TestForm(forms.Form):
> > >  name = forms.CharField( max_length=30 )
> > >  age = forms.CharField( max_length=30 )
>
> > > Then in the views.py:
>
> > > def Test_page(request):
>
> > >  form = TestForm()
> > >  variables = RequestContext(request, {
> > >    'form': form,
> > >  })
> > >  return render_to_response('Test.html', variables)
>
> > > In the temlates file, I want to add a iframe and a submit button. When
> > > the submit button was clicked, some word will appear in the iframe.
> > > The following code is the Test.html:
>
> > > 
> > > Test Result Page
> > > 
> > >      
> > >              function test(){
> > >                              var iframe = document.getElementById
> > > ("test");
> > >                              var d = iframe.contentDocument;
> > >                              d.body.innerHTML = "This is a test";
> > >                              }
> > >      
> > > 
> > > 
> > >   
> > >        Name:{{form.name}}
> > >        age: {{form.age}}
> > >        
> > >        
> > >   
> > > 
> > > 
>
> > > Now, the problem is that, when I clicked the submit button, the text
> > > of "This is a test" will display in the iframe for one second, and
> > > then disappear. Is there any one know what's wrong with my code?
>
> > > thanks
> > > min


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



Re: trouble with Django and javascript

2009-02-01 Thread min

If I use Onclick="submit();", how to add the javascript function " test
()" to that buttom?

thanks

On Feb 2, 11:58 am, "Will Matos"  wrote:
> Onclick="submit();"
> Will Matos
> TCDI
> Director of Technical Sales
> 4510 Weybridge Lane
> Greensboro, NC  27407
> 336.232.5832 office
> 336.232.5850 fax
> 336.414.0467 mobile  
>
>
>
> - Original Message -
> From: django-users@googlegroups.com 
> To: Django users 
> Sent: Sun Feb 01 19:52:49 2009
> Subject: Re: trouble with Django and javascript
>
> Thanks for you reply.
>
> However, if I change the 'submit' to button, how can I submit the form
> to the server?
>
> Regards
> min
>
> On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> > In addition to displaying the message, it's also submitting the form,
> > so you see the text for a second and then the form reloads.
>
> > Change the  instead of "submit" and see if that 
> > helps.
>
> > Todd
>
> > On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > > First I  have a form:
>
> > > class TestForm(forms.Form):
> > >  name = forms.CharField( max_length=30 )
> > >  age = forms.CharField( max_length=30 )
>
> > > Then in the views.py:
>
> > > def Test_page(request):
>
> > >  form = TestForm()
> > >  variables = RequestContext(request, {
> > >    'form': form,
> > >  })
> > >  return render_to_response('Test.html', variables)
>
> > > In the temlates file, I want to add a iframe and a submit button. When
> > > the submit button was clicked, some word will appear in the iframe.
> > > The following code is the Test.html:
>
> > > 
> > > Test Result Page
> > > 
> > >      
> > >              function test(){
> > >                              var iframe = document.getElementById
> > > ("test");
> > >                              var d = iframe.contentDocument;
> > >                              d.body.innerHTML = "This is a test";
> > >                              }
> > >      
> > > 
> > > 
> > >   
> > >        Name:{{form.name}}
> > >        age: {{form.age}}
> > >        
> > >        
> > >   
> > > 
> > > 
>
> > > Now, the problem is that, when I clicked the submit button, the text
> > > of "This is a test" will display in the iframe for one second, and
> > > then disappear. Is there any one know what's wrong with my code?
>
> > > thanks
> > > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using hashing for password checking in auth module

2009-02-01 Thread Malcolm Tredinnick

On Sun, 2009-02-01 at 01:07 -0800, Guy Rutenberg wrote:
> Hi Kless,
> 
> 
> On Jan 31, 7:05 pm, Kless  wrote:
> >
> > Your method has a point of failure. Whatever can see your code JS
> > (client-code), so he will know what are you making with the password
> > that is sent from a form.
> >
> > The best options are https or using HMAC-SHA1/RIPEMD160
> >
> 
> I've indeed referenced HMAC in couple of the previous posts. As this
> methods should be (almost) irreversable, i don't care if someone will
> take a look at the JS and figure out what I'm doing (I'm not trying to
> obtain security by obfustication). As you said, HMAC-SHA1 (or any
> other strong hash with HMAC) is a good option. I just wonder if Django
> has builtin support for using this things or I've to write my own.

Django itself does not have support for this. It's essentially out of
scope. We had a long discussion about it a couple of years back and
nothing has really changed since then (the best solution is HTTPS and
anything else is a workaround with all the drawbacks that come with it).
There might (or might not) be some third-party application to provide
it. Django is meant to be the basis on which other things are built and
this sounds like something that would be a third-party thing.

Regards,
Malcolm



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



Re: trouble with Django and javascript

2009-02-01 Thread Will Matos
Onclick="submit();"
Will Matos
TCDI
Director of Technical Sales
4510 Weybridge Lane
Greensboro, NC  27407
336.232.5832 office
336.232.5850 fax
336.414.0467 mobile  

- Original Message -
From: django-users@googlegroups.com 
To: Django users 
Sent: Sun Feb 01 19:52:49 2009
Subject: Re: trouble with Django and javascript


Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

Regards
min

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min


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



Re: django sqlite autoincrement bug

2009-02-01 Thread Malcolm Tredinnick

On Sat, 2009-01-31 at 16:56 -0500, alexander lind wrote:
>  
> > > 
> > > class User(models.Model):
> > >  user_id = models.AutoField(primary_key=True)
> > > 
> > > This produces a table in sqlite that will NOT take NULL for a
> > > value  
> > > when inserting records. You get an error back.
> > 
> > That's correct behaviour. A primary key column must be unique and
> > not
> > null. By definition. No bug there.
> 
> 
> Right. I stated it because if you do an insert and just leave the
> autoincrementing field out of the field-list, sqlite will return the
> "sorry, null is not an acceptable value for this field". I was a bit
> unclear.
> 
> > 
> > That's not the right solution. You're making the symptom go away,
> > not
> > fixing the problem itself.
> > 
> > Your observation is correct: the SQLite backend doesn't add
> > AUTOINCREMENT. The fix is to make it always add AUTOINCREMENT. An
> > AutoField is an auto-increment field: it's not optional.
> 
> 
> You're right.
> 
> > 
> > 
> > Shows how infrequently AutoField's are really used in practice.
> > They're
> > generally just not that useful to specify.
> 
> 
> What else do people use for specifying autoinc fields?

Auto-increment fields generally aren't that useful in practice, outside
of primary keys (the reasonsing being that, since they can act as
primary keys, you might as well make it the table's primary key if
you're using one. A non-primary key auto-inc field is usually a sign of
an unnecessarily denormalised data model). Since Django automatically
creates an auto-increment primary key field, the majority of the time
the manual specification isn't needed.

Regards,
Malcolm

> 


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



Re: trouble with Django and javascript

2009-02-01 Thread min

Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

Regards
min

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

Regards
min

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

Regards
min

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Thanks for you reply.

However, if I change the 'submit' to button, how can I submit the form
to the server?

On Feb 2, 11:34 am, "Todd O'Bryan"  wrote:
> In addition to displaying the message, it's also submitting the form,
> so you see the text for a second and then the form reloads.
>
> Change the  instead of "submit" and see if that 
> helps.
>
> Todd
>
>
>
> On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> > First I  have a form:
>
> > class TestForm(forms.Form):
> >  name = forms.CharField( max_length=30 )
> >  age = forms.CharField( max_length=30 )
>
> > Then in the views.py:
>
> > def Test_page(request):
>
> >  form = TestForm()
> >  variables = RequestContext(request, {
> >    'form': form,
> >  })
> >  return render_to_response('Test.html', variables)
>
> > In the temlates file, I want to add a iframe and a submit button. When
> > the submit button was clicked, some word will appear in the iframe.
> > The following code is the Test.html:
>
> > 
> > Test Result Page
> > 
> >      
> >              function test(){
> >                              var iframe = document.getElementById
> > ("test");
> >                              var d = iframe.contentDocument;
> >                              d.body.innerHTML = "This is a test";
> >                              }
> >      
> > 
> > 
> >   
> >        Name:{{form.name}}
> >        age: {{form.age}}
> >        
> >        
> >   
> > 
> > 
>
> > Now, the problem is that, when I clicked the submit button, the text
> > of "This is a test" will display in the iframe for one second, and
> > then disappear. Is there any one know what's wrong with my code?
>
> > thanks
> > min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Meta-information for model and form fields

2009-02-01 Thread Malcolm Tredinnick

On Sat, 2009-01-31 at 13:13 -0800, Vinay Sajip wrote:
> 
> 
> On Jan 30, 1:36 am, Malcolm Tredinnick 
> wrote:
> > On Wed, 2009-01-28 at 23:21 -0800, Vinay Sajip wrote:
> >
> > [...]
> >
> > > I was hoping there was another way. Of course subclassing's not hard
> > > to do, but it means doing it for every field class. I was looking at
> > > moving an application over from SQLAlchemy, which offers this feature
> > > both for models and fields.
> >
> > That's not very natural Python behaviour, though. You can't expect to
> > pass in extra arbitrary arguments to class constructors for normal
> > Python classes and have them hold onto it for later collection.
> >
> 
> I didn't find anything unusual about it. SQLAlchemy does this by
> design [1], to allow users to attach additional meta-data, which the
> SQLAlchemy team haven't thought of, to their tables and columns. 

At the risk of beating a dead horse: I didn't say it wasn't a good idea
in SQLAlchemy. I was pointing out that it isn't normal *Python*
behaviour. So it would be unexpected for a class to support that
behaviour, rather than natural.

Malcolm



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



Re: trouble with Django and javascript

2009-02-01 Thread Todd O'Bryan

In addition to displaying the message, it's also submitting the form,
so you see the text for a second and then the form reloads.

Change the  instead of "submit" and see if that helps.

Todd

On Sun, Feb 1, 2009 at 6:05 PM, min  wrote:
>
> First I  have a form:
>
> class TestForm(forms.Form):
>  name = forms.CharField( max_length=30 )
>  age = forms.CharField( max_length=30 )
>
> Then in the views.py:
>
> def Test_page(request):
>
>  form = TestForm()
>  variables = RequestContext(request, {
>'form': form,
>  })
>  return render_to_response('Test.html', variables)
>
> In the temlates file, I want to add a iframe and a submit button. When
> the submit button was clicked, some word will appear in the iframe.
> The following code is the Test.html:
>
> 
> Test Result Page
> 
>  
>  function test(){
>  var iframe = document.getElementById
> ("test");
>  var d = iframe.contentDocument;
>  d.body.innerHTML = "This is a test";
>  }
>  
> 
> 
>   
>Name:{{form.name}}
>age: {{form.age}}
>
>
>   
> 
> 
>
> Now, the problem is that, when I clicked the submit button, the text
> of "This is a test" will display in the iframe for one second, and
> then disappear. Is there any one know what's wrong with my code?
>
> thanks
> min
> >
>

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



Re: Basic question: filtering objects by date

2009-02-01 Thread Todd O'Bryan

How about:

items = Item.objects.filter(categories=category, expire_date__gt=today)

?

Todd

On Sun, Feb 1, 2009 at 2:04 PM, KJ  wrote:
>
> Hi, I want to filter objects based on whether they have expired or
> not. Each object has an expiration date. Right now, I am getting all
> the objects via this line:
>items = Item.objects.filter(categories=category)
>
> However, I only want to get the "items" which have not expired
> (expire_date > today). How can I add that check to the filter command?
>
> I recently started with Django, so be kind :)
>
> KJ
>
> >
>

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



Re: trouble with Django and javascript

2009-02-01 Thread min

Besides, I use firefox.

thanks

On Feb 2, 10:05 am, min  wrote:
> First I  have a form:
>
> class TestForm(forms.Form):
>   name = forms.CharField( max_length=30 )
>   age = forms.CharField( max_length=30 )
>
> Then in the views.py:
>
> def Test_page(request):
>
>   form = TestForm()
>   variables = RequestContext(request, {
>     'form': form,
>   })
>   return render_to_response('Test.html', variables)
>
> In the temlates file, I want to add a iframe and a submit button. When
> the submit button was clicked, some word will appear in the iframe.
> The following code is the Test.html:
>
> 
> Test Result Page
> 
>       
>               function test(){
>                               var iframe = document.getElementById
> ("test");
>                               var d = iframe.contentDocument;
>                               d.body.innerHTML = "This is a test";
>                               }
>       
> 
> 
>    
>         Name:{{form.name}}
>         age: {{form.age}}
>         
>         
>    
> 
> 
>
> Now, the problem is that, when I clicked the submit button, the text
> of "This is a test" will display in the iframe for one second, and
> then disappear. Is there any one know what's wrong with my code?
>
> thanks
> min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Besides, I use firefox.

On Feb 2, 10:05 am, min  wrote:
> First I  have a form:
>
> class TestForm(forms.Form):
>   name = forms.CharField( max_length=30 )
>   age = forms.CharField( max_length=30 )
>
> Then in the views.py:
>
> def Test_page(request):
>
>   form = TestForm()
>   variables = RequestContext(request, {
>     'form': form,
>   })
>   return render_to_response('Test.html', variables)
>
> In the temlates file, I want to add a iframe and a submit button. When
> the submit button was clicked, some word will appear in the iframe.
> The following code is the Test.html:
>
> 
> Test Result Page
> 
>       
>               function test(){
>                               var iframe = document.getElementById
> ("test");
>                               var d = iframe.contentDocument;
>                               d.body.innerHTML = "This is a test";
>                               }
>       
> 
> 
>    
>         Name:{{form.name}}
>         age: {{form.age}}
>         
>         
>    
> 
> 
>
> Now, the problem is that, when I clicked the submit button, the text
> of "This is a test" will display in the iframe for one second, and
> then disappear. Is there any one know what's wrong with my code?
>
> thanks
> min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trouble with Django and javascript

2009-02-01 Thread min

Besides, I use firefox.

On Feb 2, 10:05 am, min  wrote:
> First I  have a form:
>
> class TestForm(forms.Form):
>   name = forms.CharField( max_length=30 )
>   age = forms.CharField( max_length=30 )
>
> Then in the views.py:
>
> def Test_page(request):
>
>   form = TestForm()
>   variables = RequestContext(request, {
>     'form': form,
>   })
>   return render_to_response('Test.html', variables)
>
> In the temlates file, I want to add a iframe and a submit button. When
> the submit button was clicked, some word will appear in the iframe.
> The following code is the Test.html:
>
> 
> Test Result Page
> 
>       
>               function test(){
>                               var iframe = document.getElementById
> ("test");
>                               var d = iframe.contentDocument;
>                               d.body.innerHTML = "This is a test";
>                               }
>       
> 
> 
>    
>         Name:{{form.name}}
>         age: {{form.age}}
>         
>         
>    
> 
> 
>
> Now, the problem is that, when I clicked the submit button, the text
> of "This is a test" will display in the iframe for one second, and
> then disappear. Is there any one know what's wrong with my code?
>
> thanks
> min
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: free django hosting

2009-02-01 Thread Chris

On a similar note, http://code.google.com/p/app-engine-patch/

On Jan 30, 9:42 pm, felix  wrote:
> http://code.google.com/p/google-app-engine-django/
> of course
>
> some restrictions apply
> your mileage may vary
>
>      felix :    crucial-systems.com
>
> On Sat, Jan 31, 2009 at 1:12 AM, xankya  wrote:
>
> > hi,
> > anybody know free django hosting ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



trouble with Django and javascript

2009-02-01 Thread min

First I  have a form:

class TestForm(forms.Form):
  name = forms.CharField( max_length=30 )
  age = forms.CharField( max_length=30 )

Then in the views.py:

def Test_page(request):

  form = TestForm()
  variables = RequestContext(request, {
'form': form,
  })
  return render_to_response('Test.html', variables)

In the temlates file, I want to add a iframe and a submit button. When
the submit button was clicked, some word will appear in the iframe.
The following code is the Test.html:


Test Result Page

  
  function test(){
  var iframe = document.getElementById
("test");
  var d = iframe.contentDocument;
  d.body.innerHTML = "This is a test";
  }
  


   
Name:{{form.name}}
age: {{form.age}}


   



Now, the problem is that, when I clicked the submit button, the text
of "This is a test" will display in the iframe for one second, and
then disappear. Is there any one know what's wrong with my code?

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



Re: Auction app

2009-02-01 Thread Dave Fowler

There's Django Satchmo

http://www.satchmoproject.com/

But it doesn't do auctions yet.  I haven't heard of anything else...

On Feb 1, 12:10 pm, Erik Allik  wrote:
> Does anyone know of an app written for Django that implements a kind  
> of (simple) web-auction functionality suitable for, say, selling arts,  
> valuable old books, or just random items?
>
> Erik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django with mod_fcgid

2009-02-01 Thread MIke

Hi,

I just started looking at Django, and since I'm using mod_fcgid anyhow
for other things, I thought I'd look into using it with Django as
well. One benefit of mod_fcgid over mod_fastcgi is that it does all
process management for you, and in my impression it's quite well-
behaved.

Turns out it's quite easy to do using a modified version of Robin
Dunn's old fastcgi python module. One benefit of that module is that
it falls back transparently to cgi when running in a cgi environment,
so all that is needed to switch Django between cgi and fastcgi is to
change one line in apache config


Options ExecCGI
AddHandler fcgid-script .cgi
#  AddHandler cgi-script .cgi


Is there any interest in this, and if so, what would be a good place
to post my code? Thanks, 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Customized model methods

2009-02-01 Thread Dave Fowler

Well you might want to start by looking into django-tagging

http://code.google.com/p/django-tagging/wiki/UsefulTips

Install that for easy tags, and that link to the useful tips shows how
to retrieve and set tags.

Also instead of doing a lot of is_this() and is_that() you will
probably want to do what the tips there describe instead get a list of
the tags

>>> tag_list = blog_entry.tags()
>>> tag_list
['sports', 'whatever']

If you need to run different functions for the different tags you can
put them into a dict to execute

>>> def example_func( tag_name )
...print tag_name

>>> tag_funcs = {'sports': example_func, 'personal': example_func, 'whatever': 
>>> example_func }
>>> for tag_name in tag_list:
tag_funcs[ tag_name ]( tag_name )  # This executes the
right function from tag_funcs with input tag_name


Hope that helps?



On Feb 1, 3:58 pm, Alex Jonsson  wrote:
> Hey guys,
>
> I'm looking to create a model method like is_(), where the tag
> can be used to lookup if the object is tagged with a certain ... tag.
> Kind of like this:
>
> A blog entry is tagged "personal" and "funny".
>
> >> blog_entry.is_sports()
> False
> >> blog_entry.is_personal()
> True
> >> blog_entry.is_whatever()
>
> False
>
> You probably get the point. Could someone perhaps explain how to do it
> or point me in the right direction?
>
> Thanks,
> Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin get_urls

2009-02-01 Thread Dave Fowler

I'm adding new views to my admin models.  The documentation is here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#get-urls-self

and the following is my implementation ( I think the same thing )

from django.conf.urls.defaults import *

class AisleAdmin(admin.ModelAdmin):
def get_urls(self):
urls = super(AisleAdmin, self).get_urls()
my_urls = patterns('',
(r'^reorders/$', 'path.to.view', )
)
return my_urls + urls

The base url for the Aisle admin is /grocery/aisle/so I assume
that my new view would be at /grocery/aisle/reorders/

Its not however, I instead get this:   invalid literal for int() with
base 10: 'reorders'

I put prints inside the get_urls function to see if its getting there,
and it isn't.  I'm on the latest svn version.

What am I missing?  Any help would be great.



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



Customized model methods

2009-02-01 Thread Alex Jonsson

Hey guys,

I'm looking to create a model method like is_(), where the tag
can be used to lookup if the object is tagged with a certain ... tag.
Kind of like this:

A blog entry is tagged "personal" and "funny".

>> blog_entry.is_sports()
False
>> blog_entry.is_personal()
True
>> blog_entry.is_whatever()
False

You probably get the point. Could someone perhaps explain how to do it
or point me in the right direction?

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



Re: Inherit/Override custom Form class methods in a custom ModelForm class

2009-02-01 Thread Stewart

That's perfect.

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



Re: Merging results from two tables

2009-02-01 Thread Markus

Thanks, that did the trick!!

On Jan 31, 6:07 pm, Daniel Roseman 
wrote:
> On Jan 31, 12:27 pm, Markus  wrote:
>
>
>
> > Hi
>
> > just starting to use Django, am stuck with the following problem:
>
> > Given
>
> > class A(models.Model):
> >     ...some fields...
>
> > class B(models.Model):
> >    A = models.ForeignKey(A)
> >    some fields...
>
> > I would like to generate a Queryset that returns values from both
> > tables, ie in SQL
>
> > SELECT A.field1, A.field2, B.field1, B.field2
> > FROM A, B
> > WHERE A.id = B.A_id AND some filter on A AND .. some further
> > conditions to ensure only one row from table B is matched
>
> > So far, I found a way to achieve this using the extra operator:
>
> > A.objects.filter(..some filter on A..).extra(select={'field1': "select
> > B.field1 from B ...", 'field2': 'select B.field2 from B ..."})
>
> > This quickly becomes clumsy as the number of fields in table B
> > increases. There must be a better way? As I couldnt find anything in
> > the documentation, I would appreciate a nudge in the right direction.
>
> > Thanks
> > Markus
>
> You haven't explained exactly what you want from B - all the values,
> or just the ones that have values in A, or just the ones for a single
> value of A?
>
> If you just want all the associated B for each value of A, then a
> simple queryset will do the trick.
> qs = A.objects.all()
> for a in qs:
>     print a.b_set.all()
>
> You can make this a bit more efficient by calling the initial queryset
> with select_related.
> qs = A.objects.all().select_related()
>
> I would suggest reading the section on related objects 
> again:http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "invalid reference to FROM-clause" for nested annotate query

2009-02-01 Thread omat

Hi,

TaggedItem model is as follows:


class TaggedItem(models.Model):
tag = models.ForeignKey(Tag, verbose_name=_('tag'),
related_name='items')
added = models.DateTimeField(auto_now_add=True)
content_type = models.ForeignKey(ContentType, verbose_name=_
('content type'))
object_id = models.PositiveIntegerField(_('object id'),
db_index=True)
object = generic.GenericForeignKey('content_type', 'object_id')


And I am using sqlite on Mac OS X with django revison 9781.


Thanks,
oMat



On Feb 1, 1:12 am, Russell Keith-Magee  wrote:
> On Sun, Feb 1, 2009 at 12:44 AM,omat wrote:
>
> > Hi all,
>
> > I obtain a list of tag ids by:
> > tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max
> > ('added'))[:10]
>
> > and try to use it in the following query to obtain tag objects:
> > Tag.objects.filter(id__in=tag_ids)
>
> > But i get "invalid reference to FROM-clause" error:
>
> > Caught an exception while rendering: invalid reference to FROM-clause
> > entry for table "tagging_taggeditem"
> > LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX
> > ("tagging_t...
> >                                                             ^
> > HINT:  Perhaps you meant to reference the table alias "u0".
>
> > If I force the first query to be evaluated, using the step syntax (ie
> > [:10:1] instead of [:10]), then everthing works fine.
>
> > Seems like a bug?
>
> I'm not seeing this failure on SQLite, Postgres or MySQL. However, I
> was testing using my own test models, not your models - it's possible
> that the problem could be caused by the interaction of some other
> property of your model on the aggregate query.
>
> Can you provide the full definition of the TaggedItem model you are
> using? It would also be helpful to know the database version and
> operating system you are using.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Writing custom model fields with Multi-table inheritance

2009-02-01 Thread Viktor

Hi,

did you got any response or did you managed to solve your problem?
I've just started to search for a UUIDField, and it would be great to
have proper uuid columns for postgres.

If so do you plan to commit it to django_extensions?

Thanks, Viktor

On 2008 dec. 16, 22:53, gordyt  wrote:
> Howdy Folks!
>
> I wanted to be able to have UUID primary keys for certain models.
> I found the implementation done by the django_extensions project
> (http://code.google.com/p/django-command-extensions/) and it works
> fine
> as is.
>
> But I wanted to be able to have a UUIDField that stored its values in
> an
> actual 'uuid' column if we were using PostgreSQL.  For all other
> databases
> it would use the same char(36) field as in the original
> implementation.
> This was for performance reasons, by the way.
>
> So listed below was my attempt at creating a UUIDField (based on the
> django_extensions one) that would do that.  It works great in every
> situation EXCEPT if I am working with a model that inherits from
> another
> model.
>
> Before I go any further, let me say that I've posted all of this
> on a web site so that it can be seen with nicer formatting than what
> is
> possible in a newsgroup post.  The URL for that page is:
>
> http://www.gordontillman.info/computers/41-django/94-django-uuidfield...
>
> -- or --
>
> http://tinyurl.com/6rnsya
>
> I've included the complete UUIDField definition, some sample models,
> and a small test case.
>
> Here is an interesting part.  The to_python() method of the UUIDField
> is supposed to return an instance of uuid.UUID.  This is my original
> implementation of that method:
>
>     def to_python(self, value):
>         if not value:
>             return None
>         if isinstance(value, uuid.UUID):
>             return value
>         # attempt to parse a UUID
>         return uuid.UUID(smart_unicode(value))
>
> This original implementation words great unless I'm working with a
> model that inherits from a base model that uses the UUIDField as its
> primary key.  If I change the implementation to this then the test
> case
> passes, both for the base model and the inherited model.  But of
> course
> now it is returning a string, not a uuid.UUID value.
>
>     def to_python(self, value):
>         if not value:
>             return None
>         if isinstance(value, uuid.UUID):
>             return smart_unicode(value)
>         else:
>             return value
>
> I was wondering if anyone could suggest an improvement to my
> UUIDField implementation so that (1) to_python() returns a proper
> uuid.UUID instance and (2) I can still use 'uuid' columns in
> databases that support it.
>
> It's possible there is a bug in the part of the Django code that
> deals with inherited models, but I'm sure it's way more likely
> that there is a bug in my UUIDField!
>
> -- begin UUIDField --
> import uuid
>
> from django.forms.util import ValidationError
> from django import forms
> from django.db import models
> from django.utils.encoding import smart_unicode
> from django.utils.translation import ugettext_lazy
>
> class UUIDVersionError(Exception):
>     pass
>
> class UUIDField(models.Field):
>     """Encode and stores a Python uuid.UUID in a manner that is
> appropriate
>     for the given datatabase that we are using.
>
>     For sqlite3 or MySQL we save it as a 36-character string value
>     For PostgreSQL we save it as a uuid field
>
>     This class supports type 1, 2, 4, and 5 UUID's.
>     """
>     __metaclass__ = models.SubfieldBase
>
>     _CREATE_COLUMN_TYPES = {
>         'postgresql_psycopg2': 'uuid',
>         'postgresql': 'uuid'
>     }
>
>     def __init__(self, verbose_name=None, name=None, auto=True,
> version=1,
>         node=None, clock_seq=None, namespace=None, **kwargs):
>         """Contruct a UUIDField.
>
>         @param verbose_name: Optional verbose name to use in place of
> what
>             Django would assign.
>         @param name: Override Django's name assignment
>         @param auto: If True, create a UUID value if one is not
> specified.
>         @param version: By default we create a version 1 UUID.
>         @param node: Used for version 1 UUID's.  If not supplied, then
> the
>             uuid.getnode() function is called to obtain it.  This can
> be slow.
>         @param clock_seq: Used for version 1 UUID's.  If not supplied
> a random
>             14-bit sequence number is chosen
>         @param namespace: Required for version 3 and version 5 UUID's.
>         @param name: Required for version4 and version 5 UUID's.
>
>         See Also:
>           - Python Library Reference, section 18.16 for more
> information.
>           - RFC 4122, "A Universally Unique IDentifier (UUID) URN
> Namespace"
>
>         If you want to use one of these as a primary key for a Django
>         model, do this::
>             id = UUIDField(primary_key=True)
>         This will currently I{not} work with Jython because PostgreSQL
> su

Re: Cookie test in login() view

2009-02-01 Thread Akbar

Thanks Karen.

I have raised ticket #10166



On Feb 1, 1:23 am, Karen Tracey  wrote:
> On Sat, Jan 31, 2009 at 9:36 PM, Akbar  wrote:
>
> > Hi,
>
> > The cookie test in django.contrib.auth.views.login() view doesn't seem
> > to work as expected. I disabled cookies in my browser for the
> > following test.
>
> > 1. The view is called via a GET request and displays the login
> > template/form. The test cookie is set.
> > 2. The form is posted back to the view. The view is supposed to check
> > for the test cookie and throw an error if cookie is not found. This
> > check doesn't happen.
>
> > The documentation of the init method of AuthenticationForm says it
> > will validate that cookies are enabled only if a request is passed in
> > when instantiating the form. But on POST the login view doesn't pass
> > the request.
>
> > I copied the code from the login view and modified it to pass the
> > request and the cookie test works.
>
> > Is it a defect in the login view or am I doing something wrong?
>
> > I am using Django 1.0.2 Final.
>
> Looks like a bug, likely an oversight from when the view was change to use
> the new forms structure instead of the old manipulators.  Please open a
> ticket for it.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Basic question: filtering objects by date

2009-02-01 Thread KJ

Hi, I want to filter objects based on whether they have expired or
not. Each object has an expiration date. Right now, I am getting all
the objects via this line:
items = Item.objects.filter(categories=category)

However, I only want to get the "items" which have not expired
(expire_date > today). How can I add that check to the filter command?

I recently started with Django, so be kind :)

KJ

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



Re: Application design question

2009-02-01 Thread eddie

Thanks Alex, that was exactly what I was looking for.

On Jan 31, 8:06 pm, "alex.gay...@gmail.com" 
wrote:
> On Jan 31, 8:04 pm, eddie  wrote:
>
>
>
> > Hey guys & girls,
>
> > I've just started playing with django, and am not sure of the best way
> > to do something.
>
> > I've got a basic site, where page a displays model a, page b displays
> > model b, etc.  Every model has it's own view function and template,
> > all extending a base template with a header, footer, etc.  In every
> > page's footer, I would like to add a parsed RSS feed (just an ul of
> > links).
>
> > I don't want to repeat code, so I don't feel like calculating it and
> > sending it to every render_to_response that I've got (I'll worry about
> > caching later, by the way).  So I wonder if there is a way that I
> > could give every template access to this object without adding it to
> > my views... though this seems like a kind of "global variable" type
> > situation that I'm a little wary of too.
>
> > How would you proceed?
>
> > Thanks!
> > -e
>
> Take a look at implementing a template context processor.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Auction app

2009-02-01 Thread Erik Allik

Does anyone know of an app written for Django that implements a kind  
of (simple) web-auction functionality suitable for, say, selling arts,  
valuable old books, or just random items?

Erik

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



Re: URL mismatch when moving from django server to apache server on windows

2009-02-01 Thread Karen Tracey
On Sun, Feb 1, 2009 at 9:04 AM, Robert  wrote:

>
> I have set up apache with mod_python and I am able to get django
> working.
>
> I am trying to reach the simple poll application that is in the
> djangoproject tutorial.
>
> I have to add "mysite" in the url when I work with apache. This wasn't
> the case with the django server.
>

You have to add mysite to the URLs in order for the request to be routed to
Django?  That sounds like you have put '/mysite/' in the Location block that
you added to your Apache config for Django.  Is that correct?  If so, that
tells Apache you want to route only URLs that start with /mysite/ to
mod_python, so, yes, you would need to include /mysite/ at the beginning of
the URL if you want it to be handled by your Django code running under
mod_python.


>
> http://localhost/mysite/polls/
>
> gives the django error message:
>
> Using the URLconf defined in mysite.urls, Django tried these URL
> patterns, in this order:
> [..]
> The current URL, /mysite/polls/, didn't match any of these.
>

For future reference, including list of URLs printed by the message wouldn't
hurt.  In this case I can probably guess what they were, but it is usually
better to include the full text of error messages and tracebacks (or point
to them on somplace like dpaste.com).

So, the problem is you need to add /mysite/ at the front of the URLs in
order to get the request routed to mod_python/Django, but the Django URL
configuration doesn't include the /mysite/ part so it cannot figure out what
to do with the request.


> I have tried to change the urls in urls.py but this will lead to other
> errors down the road. Is it possible to handle this differently?
>

Yes, there are two ways to fix this without changing your URL
configuration.  First -- do you really want Apache to route only URLs that
start with /mysite/ to mod_python/Django or would you actually prefer Apache
to route everything (minus perhaps some specific prefixes for static files)
to mod_python/Django?  I have a feeling you may have put the /mysite/ in the
Location block because that is what is in the sample provided in the docs.
If that is the only reason it is there, and you are really planning on your
entire site to be served by Django code, then you can just change the
Location block to  and you will no longer need to prepend
/mysite/ to the URLs.

If you do, however, only want a subset of your site's entire URL tree to be
routed by Apache to mod_python/Django, then you can leave the  as it is, and add a django.root PythonOption as described here:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basic-configuration


>
> This is my pythonpath in httpd.conf:
> PythonPath "['c:/Pythonprojects'] + sys.path"
> This is the reference to the settings:
> SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>

The fact that the request got as far as failing to match anything in your
url configuration implies these settings are fine.  The first setting
ensures that the Python interpreter can find your code, and the second
ensures that Django code, when it gets control, can find your project
settings.  Your code and settings had to have been found for the request to
get as far as it did, and neither has anything to do with URL routing
(except indirectly, as your settings points to your url config).  (I'm not
trying to be annoying here -- I'm just pointing this out in an effort to
help you see how all the pieces of the various config settings fit
together.)

Karen

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



Re: __icontains in case of non ascii symbols

2009-02-01 Thread Karen Tracey
On Sun, Feb 1, 2009 at 6:57 AM, Konstantin S  wrote:

>
> Hello again :)
>
> Am I right that __icontains relays on DB backend entirely to perform
> case insensitive search ?
>

Yes.

Karen

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



Re: Three table Lookup Question

2009-02-01 Thread Karen Tracey
On Sun, Feb 1, 2009 at 4:36 AM, Kyle  wrote:

> Hello again.
>
> I have one more question about the three table lookup I am trying to
> complete.
>
> The details of my situation are posted here: http://dpaste.com/115244/
>
> Does anybody have any idea on how to use django's ORM to perform two INNER
> JOINS, a WHERE, and an ORDER BY?
>
> Thanks in advance for any help and further guidance!
>
>
Try:

Project.objects.filter(campaign__industry__industry=1).order_by('campaign__industry__gridorder')

Karen

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



URL mismatch when moving from django server to apache server on windows

2009-02-01 Thread Robert

I have set up apache with mod_python and I am able to get django
working.

I am trying to reach the simple poll application that is in the
djangoproject tutorial.

I have to add "mysite" in the url when I work with apache. This wasn't
the case with the django server.

http://localhost/mysite/polls/

gives the django error message:

Using the URLconf defined in mysite.urls, Django tried these URL
patterns, in this order:
[..]
The current URL, /mysite/polls/, didn't match any of these.

I have tried to change the urls in urls.py but this will lead to other
errors down the road. Is it possible to handle this differently?

This is my pythonpath in httpd.conf:
PythonPath "['c:/Pythonprojects'] + sys.path"
This is the reference to the settings:
SetEnv DJANGO_SETTINGS_MODULE mysite.settings

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



Re: commit=False and m2m relations in forms

2009-02-01 Thread Russell Keith-Magee

On Sun, Feb 1, 2009 at 9:53 PM, Konstantin  wrote:
>
> On Feb 1, 2:23 pm, Russell Keith-Magee  wrote:
>> Yes. Read up on how to use the save() method in the modelforms docs.
>>
>> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
>>
>> In particular, the second example in that section should answer your 
>> question.
>>
>
> Thanks, Russ, it works. I've overlooked that part of docs. But it
> seems that this method is not transaction safe ?

What makes you say that? The method is a completely transaction
neutral implementation - it will follow whatever transaction behavior
is in place at the time you invoke it.

Yours,
Russ Magee %-)

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



Re: commit=False and m2m relations in forms

2009-02-01 Thread Konstantin

On Feb 1, 2:23 pm, Russell Keith-Magee  wrote:
> Yes. Read up on how to use the save() method in the modelforms docs.
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
>
> In particular, the second example in that section should answer your question.
>

Thanks, Russ, it works. I've overlooked that part of docs. But it
seems that this method is not transaction safe ?

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



Re: Using hashing for password checking in auth module

2009-02-01 Thread Kless

Hi Rutenberg,

I just find anything that can be of interest for you. It's a "secure"
method to login without https. Althought it isn't realy secure in
comparison to https.

http://www.pylucid.org/about/features/JS-SHA-Login/


On 1 feb, 09:07, Guy Rutenberg  wrote:
> I just wonder if Django
> has builtin support for using this things or I've to write my own.

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



__icontains in case of non ascii symbols

2009-02-01 Thread Konstantin S

Hello again :)

Am I right that __icontains relays on DB backend entirely to perform
case insensitive 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: docs: Problem with 'make html'

2009-02-01 Thread Ramiro Morales

On Sat, Jan 31, 2009 at 8:48 AM, Benjamin Buch  wrote:
>
> Hi,
>
> if I do 'make html' in my django-trunk/docs directory, I get this error:
>
> [...]
>
> Traceback (most recent call last):
>   File "/opt/local/lib/python2.5/site-packages/sphinx/__init__.py",
> line 114, in main
> confoverrides, status, sys.stderr, freshenv)
>   File "/opt/local/lib/python2.5/site-packages/sphinx/
> application.py", line 81, in __init__
> self.setup_extension(extension)
>   File "/opt/local/lib/python2.5/site-packages/sphinx/
> application.py", line 120, in setup_extension
> mod.setup(self)
>   File "/Users/benjamin/Code/django/django-trunk/docs/_ext/
> djangodocs.py", line 15, in setup
> app.add_crossref_type(
> AttributeError: 'Sphinx' object has no attribute 'add_crossref_type'
>
> I'm using a recent version of django.

Which version of Sphinx are you using?.

-- 
 Ramiro Morales

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



Re: commit=False and m2m relations in forms

2009-02-01 Thread Russell Keith-Magee

On Sun, Feb 1, 2009 at 8:12 PM, Konstantin S  wrote:
>
> Hello!
>
> I couldn't add m2m relations in my form if I use delayed commit, i.e.
> form.save(commit = False) and form.save() later on. See code at
> http://dpaste.com/hold/115253/. Is there some common pattern to
> workaround such issues ?

Yes. Read up on how to use the save() method in the modelforms docs.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

In particular, the second example in that section should answer your question.

Yours,
Russ Magee %-)

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



commit=False and m2m relations in forms

2009-02-01 Thread Konstantin S

Hello!

I couldn't add m2m relations in my form if I use delayed commit, i.e.
form.save(commit = False) and form.save() later on. See code at
http://dpaste.com/hold/115253/. Is there some common pattern to
workaround such issues ?

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



Re: Someone using django trunk for production?

2009-02-01 Thread Russell Keith-Magee

On Sat, Jan 31, 2009 at 7:24 PM, Alessandro Ronchi
 wrote:
>
> I need to use aggregation features of django 1.1 (i need AVG, SUM).
>
> My production site uses 1.0.2.
>
> Can I upgrade to trunk without worrying?

Would I expect to see any major failures? No.

Would I keep my eyes open just in case? Yes.

We try fairly hard to keep trunk stable, and there haven't been any
backwards incompatible changes to public API, so I wouldn't expect to
see any major problems in switching from v1.0.2 to trunk SVN. However,
there will occasionally be bugs in trunk (such as the file field
problem Andrew mentioned). If you intend to move to trunk, you need to
plan on testing a little more thoroughly than you would need to under
v1.0.2, and sometimes you may need to patch your local trunk checkout
to overcome bugs that have not yet been fixed. The extent to which
these bugs affect you will depend entirely upon your own codebase.

You will need to balance your willingness to deal with these problems
against your desire to use the new aggregate features. Ultimately, you
are the only person that can make that call.

Yours,
Russ Magee %-)

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



Re: Using ./manage.py test without a database and with a custom test runner fails

2009-02-01 Thread Russell Keith-Magee

On Sun, Feb 1, 2009 at 7:42 PM, Jarkko Laiho  wrote:
>
>> The doc about defining a different test runner starts with the assumption
>> you are not using Django's test framework -- I read that to mean you are not
>> using django.test.TestCase tests, for example.  You can't just rip out the
>> database-create/destroy parts of the test runner and still expect to run
>> django.test.TestCase tests to still run, since they do assume a database
>> exists.
>
> OK, thanks for the info. I misinterpreted RKM's advice as saying that
> a database is not needed, whereas it now (having read your message)
> looks like he meant that a database is needed, but not necessarily
> through Django's ORM.

Sounds like some wires are getting crossed here.

Django's test framework contains several parts. There is the command
line hook that lets you invoke "manage.py test". There is a bunch of
global setup and teardown methods. There are some service mocks. There
is the test client that emulates a web browser. And there is the
Django TestCase class.

The Django TestCase requires the existence of a database, because it
exists to provide common database-centric testing services for Django
applications - in particular, setting up fixtures. If you're writing
tests that don't require the use of a database, you won't be able to
use the Django TestCase - but that's ok, because it wouldn't be giving
you anything interesting anyway. You can use standard Python
unittest.TestCase, though, and it will still be picked up by the
Django test runner.

There is nothing in the command line hook that requires the existence
of a database - other than the need to use a custom test runner like I
previously advised. With a custom, databaseless test running, you
should have no difficulty running tests inside the Django test
framework.

Yours,
Russ Magee %-)

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



Re: Using ./manage.py test without a database and with a custom test runner fails

2009-02-01 Thread Jarkko Laiho

> The doc about defining a different test runner starts with the assumption
> you are not using Django's test framework -- I read that to mean you are not
> using django.test.TestCase tests, for example.  You can't just rip out the
> database-create/destroy parts of the test runner and still expect to run
> django.test.TestCase tests to still run, since they do assume a database
> exists.

OK, thanks for the info. I misinterpreted RKM's advice as saying that
a database is not needed, whereas it now (having read your message)
looks like he meant that a database is needed, but not necessarily
through Django's ORM.

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



Anyone know how to install and run django on IronPython 2.0?

2009-02-01 Thread IL

I'm a new coming. I know MS has showed the django on IronPython.
But I failed to do this.
Anyone can help?

Django 1.0.2
IronPython 2.0
OS: winXP sp3
command:
ipy.exe setup.py install

Failed and show "File c:\documents does not exist."

I copy from cpython folder directly, and try Template.

IronPython console:
>>> from django.template import Template
>>> t = Template("My name is {{my_name}}.")
Traceback (most recent call last):
File "", line 1, in 
File "E:\Development\IronPython 2.0\lib\site-packages\django\template
\__init__
.py", line 164, in __init__
File "E:\Development\IronPython 2.0\lib\site-packages\django\conf
\__init__.py"
, line 28, in __getattr__
File "E:\Development\IronPython 2.0\lib\site-packages\django\conf
\__init__.py"
, line 57, in _import_settings
ImportError: Settings cannot be imported, because environment variable
DJANGO_SE
TTINGS_MODULE is undefined.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Three table Lookup Question

2009-02-01 Thread Kyle
Hello again.

I have one more question about the three table lookup I am trying to
complete.

The details of my situation are posted here: http://dpaste.com/115244/

Does anybody have any idea on how to use django's ORM to perform two INNER
JOINS, a WHERE, and an ORDER BY?

Thanks in advance for any help and further guidance!

On Thu, Jan 29, 2009 at 4:00 PM, Kyle  wrote:

> Yes, almost.  It got me to understand the correct syntax.
>
> I noticed that my results were coming according to Industry's primary key,
> rather than the Industry integer field, so I appended another __industry
>
> Here is the solution:
>
> Project.objects.filter(campaign__industry__industry=x)
>
> Thank you for your guidance, Todd.
>
>
> On Thu, Jan 29, 2009 at 12:33 PM, Todd O'Bryan wrote:
>
>>
>> I'm not sure I understand what you're asking, but
>>
>> projs = Project.objects.filter(campaign__industry=x)
>>
>> where x is one of 1-6 should do what you want, I think.
>>
>> Is that what you were asking?
>>
>> On Thu, Jan 29, 2009 at 9:54 AM, Kyle  wrote:
>> >
>> > Hello!
>> >
>> > I am trying to get a list of "Projects" based on certain "Industry".
>> > (My naming convention, not django's)
>> >
>> > My models look like this:
>> > http://dpaste.com/114308/
>> >
>> > "Project" has a foreign key to "Campaign".
>> >
>> > "Industry" also has a foreign key to "Campaign".
>> >
>> > Does it matter if both relationships are pointing to the center model
>> > in the data route I am trying to setup?  Like this:
>> >
>> > Project -> Campaign <- Industry
>> >
>> > If Industry = 3, and a handful of Campaigns are returned, I would like
>> > a list of all the Projects contained in each of the Campaigns
>> > returned.
>> >
>> > How do I do this with django models?
>> >
>> > >
>> >
>>
>> >>
>>
>
>
> --
> Light Emitter
> Think in 3D Studios
> www.thinkin3d.net
>



-- 
Light Emitter
Think in 3D Studios
www.thinkin3d.net

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



docs: Problem with 'make html'

2009-02-01 Thread Benjamin Buch

Hi,

if I do 'make html' in my django-trunk/docs directory, I get this error:

mkdir -p _build/html _build/doctrees
sphinx-build -b html -d _build/doctrees   . _build/html
Exception occurred:
   File "/Users/benjamin/Code/django/django-trunk/docs/_ext/ 
djangodocs.py", line 15, in setup
 app.add_crossref_type(
AttributeError: 'Sphinx' object has no attribute 'add_crossref_type'
The full traceback has been saved in /var/folders/Yb/ 
YbJi1xdnH98ZWGMLUVZ5GU+++TI/-Tmp-/sphinx-err-SPVwHe.log, if you want  
to report the issue to the author.
Please also report this if it was a user error, so that a better error  
message can be provided next time.
Send reports to ge...@python.org. Thanks!
make: *** [html] Error 1

This is the full traceback:

Traceback (most recent call last):
   File "/opt/local/lib/python2.5/site-packages/sphinx/__init__.py",  
line 114, in main
 confoverrides, status, sys.stderr, freshenv)
   File "/opt/local/lib/python2.5/site-packages/sphinx/ 
application.py", line 81, in __init__
 self.setup_extension(extension)
   File "/opt/local/lib/python2.5/site-packages/sphinx/ 
application.py", line 120, in setup_extension
 mod.setup(self)
   File "/Users/benjamin/Code/django/django-trunk/docs/_ext/ 
djangodocs.py", line 15, in setup
 app.add_crossref_type(
AttributeError: 'Sphinx' object has no attribute 'add_crossref_type'

I'm using a recent version of django.

Any ideas?


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



Re: Using hashing for password checking in auth module

2009-02-01 Thread Guy Rutenberg

Hi Kless,


On Jan 31, 7:05 pm, Kless  wrote:
>
> Your method has a point of failure. Whatever can see your code JS
> (client-code), so he will know what are you making with the password
> that is sent from a form.
>
> The best options are https or using HMAC-SHA1/RIPEMD160
>

I've indeed referenced HMAC in couple of the previous posts. As this
methods should be (almost) irreversable, i don't care if someone will
take a look at the JS and figure out what I'm doing (I'm not trying to
obtain security by obfustication). As you said, HMAC-SHA1 (or any
other strong hash with HMAC) is a good option. I just wonder if Django
has builtin support for using this things or I've to write my own.

Thanks,

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



Re: User Profiles and Fixtures

2009-02-01 Thread stryderjzw

Well, it looks like I was able to solve this particular problem.

In the fixtures, I changed the order when loading the data. I now load
the Profile first, and then the User. That works.

I guess writing the problem down helped me think of potential
solutions.  :P

Still, I'm going to have to alter dumpdata manually everytime.


On Feb 1, 12:22 am, stryderjzw  wrote:
> Hi!
>
> I did some searching, but I felt it's going nowhere, so here's the
> question.
>
> I'm using Django 1.1 r9756, the one where tests are using
> transactions.
>
> I have a user profile automatically created with signals, as below:
>
> def create_player(sender, instance=None, **kwargs):
>         if instance is None:
>                 return
>         player, created = Player.objects.get_or_create(user=instance)
> post_save.connect(create_player, sender=User)
>
> When I run multiple tests together, it gives me IntegrityError:
>
> IntegrityError: duplicate key value violates unique constraint
> "agent_player_user_id_key"
>
> It seems like it's trying to create the player again, but can't
> because its' already created.
>
> Anyone else run into this problem?
>
> Thanks!
> Justin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



User Profiles and Fixtures

2009-02-01 Thread stryderjzw

Hi!

I did some searching, but I felt it's going nowhere, so here's the
question.

I'm using Django 1.1 r9756, the one where tests are using
transactions.

I have a user profile automatically created with signals, as below:

def create_player(sender, instance=None, **kwargs):
if instance is None:
return
player, created = Player.objects.get_or_create(user=instance)
post_save.connect(create_player, sender=User)


When I run multiple tests together, it gives me IntegrityError:

IntegrityError: duplicate key value violates unique constraint
"agent_player_user_id_key"


It seems like it's trying to create the player again, but can't
because its' already created.

Anyone else run into this problem?

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