Re: Deleting m2m relationship without deleting the data

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 22:38 -0800, I.A wrote:
> Hi guys,
> I apologize for the confusing title.
> 
> I'm still confused on using the models in a m2m relationship. Suppose
> I have the models below from the tutorials on the django site:
> 
> class Author(models.Model):
> name = models.CharField(max_length=50)
> email = models.EmailField()
> 
> def __unicode__(self):
> return self.name
> 
> class Entry(models.Model):
> blog = models.ForeignKey(Blog)
> headline = models.CharField(max_length=255)
> body_text = models.TextField()
> pub_date = models.DateTimeField()
> authors = models.ManyToManyField(Author)
> 
> If I have the Author that I want I can get all the entries related to
> this Author by doing
> 
> query_set = author.entry_set.all()
> 
> If I do query_set.delete() at this point, I know it will delete all
> the Entry data that relates to the particular Author, which will also
> delete all relationships the other Authors had with the Entries in the
> query_set.
> 
> How do I then delete just the relationship of that particular Author
> to those Entries without effecting other Author's relationship (i.e
> deleting the data in the intermediary table only). If the are no other
> Authors relating to these Entries, it would be ok then to delete those
> Entries too.

There's a clear() method that works on reverse relations. It's only
documented ([1]) as being for ForeignKey fields, but I just tested it
(after finding it by browsing the source) and it appears to work on
ManyToManyFields as well. Thus,

author.entry_set.clear()

does what you're after. It won't remove any Entry objects that
subsequently end up with zero attached authors, as noted in the
documentation. You'll have to do an extra query for that:

Entry.objects.filter(authors=None).delete()

[1] http://docs.djangoproject.com/en/dev/ref/models/relations/

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: html a-href

2009-01-19 Thread urukay


try look at this:

http://www.w3schools.com/html/html_links.asp

R.



lperkov wrote:
> 
> hi, i'm pretty new in django.. so i have basic problems :) 
> ..my index file (work in browser) don't want to link other pages.. i have
> done all that stuff with registration template folder.. 
> {{include somepage.html}} is working, too.. only when i write "a
> href="somepage.html"" is not working..
> 
> can someone now what is the problem??
> 
> tnx everyone!
> 

-- 
View this message in context: 
http://www.nabble.com/html-a-href-tp21533102p21558028.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Multiple images in form

2009-01-19 Thread DragonSlayre

I'm using django-thumbs (http://code.google.com/p/django-thumbs/), and
the problem with it is that you can't stick blank=True, null=True when
you declare a field in your model.

To get around this, I thought I'd wrap it in another model, and
reference it from my Posting model, which contains information for a
post (text and picture etc etc).  This works fine for one picture,
but I wanted say five - I tried to reference 5 of them by having 5
foreign key fields to the same model - but django didn't like that
very much and gave me a whole heap of errors - is there a way around
this?

My models look a bit like this:

class Image(models.Model):
photo = ImageWithThumbsField(
upload_to="static/site_images",
sizes=((thumb_widths,thumb_heights),))

class Posting(models.Model):
'''An abstract class to represent a listing '''
#main data
title = models.CharField(max_length=200)
body_text = models.TextField()

#Listing images
first_photo = models.ForeignKey(Image, blank=True, null=True)
second_photo = models.ForeignKey(Image, blank=True, null=True)
third_photo = models.ForeignKey(Image, blank=True, null=True)
fourth_photo = models.ForeignKey(Image, blank=True, null=True)
fifth_photo = models.ForeignKey(Image, blank=True, null=True)

class PostingForm(ModelForm):
class Meta:
model = Posting


This gives me loads of errors - i'm pretty sure it's because of the
ForeignKeys.


Thoughts?


On Jan 20, 5:48 pm, DragonSlayre  wrote:
> Hi,
>
> I've seen some posts from a while back, but didn't find any real
> solution when searching to find out how to put multiple images (or any
> field for that matter) into a form (mainly a  ModelForm)
>
> Basically what I want to have is a form that has a one to many
> relationship from a post to images, and to allow 5 images to be
> displayed on the form.
>
> Any simple way of doing this?
>
> If not, any other ways that people can think of/have done?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Deleting m2m relationship without deleting the data

2009-01-19 Thread I.A

Hi guys,
I apologize for the confusing title.

I'm still confused on using the models in a m2m relationship. Suppose
I have the models below from the tutorials on the django site:

class Author(models.Model):
name = models.CharField(max_length=50)
email = models.EmailField()

def __unicode__(self):
return self.name

class Entry(models.Model):
blog = models.ForeignKey(Blog)
headline = models.CharField(max_length=255)
body_text = models.TextField()
pub_date = models.DateTimeField()
authors = models.ManyToManyField(Author)

If I have the Author that I want I can get all the entries related to
this Author by doing

query_set = author.entry_set.all()

If I do query_set.delete() at this point, I know it will delete all
the Entry data that relates to the particular Author, which will also
delete all relationships the other Authors had with the Entries in the
query_set.

How do I then delete just the relationship of that particular Author
to those Entries without effecting other Author's relationship (i.e
deleting the data in the intermediary table only). If the are no other
Authors relating to these Entries, it would be ok then to delete those
Entries too.


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



Re: Built-in Template Reference in Admin

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 20:46 -0800, Kerr wrote:
> Hi all, I'm reading through the Django book online and am currently on
> chapter 10.  http://djangobook.com/en/1.0/chapter10/
> 
> Near the end it mentions a built-in template reference available from
> the admin interface, which contains info for all tags and filters
> available for a given site.  In particular, the book states:
> 
> "Django’s admin interface includes a complete reference of all
> template tags and filters available for a given site. It’s designed to
> be a tool that Django programmers give to template developers. To see
> it, go to the admin interface and click the Documentation link at the
> upper right of the page."
> 
> I've enabled and am using the admin interface, but I don't see any
> mention of 'Documentation' on the admin pages.  I viewed the source
> just to see if something may be hidden and still found nothing.  I
> understand that the online book was written for 0.96, so I looked at
> the newest iteration of the book and it only has chapters 1-3 posted.
> Am I missing something related to this built-in reference?

The admindoc application was separated from admin in Django 1.0.
Ironically, we haven't documented admindoc much in the documentation,
but there are some details about how to port from 0.96 to 1.0 at [1].

However, by far the simplest way to enable the admin documentation is to
open up your urls.py and read the comment just above the line that
includes the word admindoc. :-)

[1]
http://code.djangoproject.com/wiki/NewformsAdminBranch#Movedadmindocviewsintodjango.contrib.admindocs

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: Built-in Template Reference in Admin

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 11:46 PM, Kerr  wrote:

>
> Hi all, I'm reading through the Django book online and am currently on
> chapter 10.  http://djangobook.com/en/1.0/chapter10/
>
> Near the end it mentions a built-in template reference available from
> the admin interface, which contains info for all tags and filters
> available for a given site.  In particular, the book states:
>
> "Django's admin interface includes a complete reference of all
> template tags and filters available for a given site. It's designed to
> be a tool that Django programmers give to template developers. To see
> it, go to the admin interface and click the Documentation link at the
> upper right of the page."
>
> I've enabled and am using the admin interface, but I don't see any
> mention of 'Documentation' on the admin pages.  I viewed the source
> just to see if something may be hidden and still found nothing.  I
> understand that the online book was written for 0.96, so I looked at
> the newest iteration of the book and it only has chapters 1-3 posted.
> Am I missing something related to this built-in reference?
>

That admin docs bit got moved into its own app shortly before 1.0 was
released.  The entry you need to include in your url configuration is shown
here:

http://docs.djangoproject.com/en/dev/intro/tutorial02/#activate-the-admin-site

along with a comment about the app that needs to be added to INSTALLED_APPS,
though I don't think the tutorial discusses it at all, so it's not in bold
face.

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: HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 19:47 -0800, csingley wrote:
> 
> On Jan 19, 9:05 pm, Malcolm Tredinnick 
> wrote:

[...]
> > In that sort of situation, it is the responsibility of the external
> > webserver to rewrite any outgoing URLs correctly for the external world.
> > Thus, it should know that it is converting an incoming HTTPS request to
> > an HTTP request and thus convert any URLs for the local hostname back
> > again before replying. In Apache, for example, this is often done with
> > the ProxyPassReverse directive in the mod_proxy module.
> 
> The gentleman wins a large stuffed bear!  I cleverly neglected to
> configure the ProxyPassReverse directive... as I said, I'm not the
> sharpest knife in the drawer.  Rectifying this clears up the problem.

Yep, that'll do it. I've only made the same error about 270 times in the
past. It becomes a likely suspect after the first couple of hundred
occurrences.

> 
> Thanks very much for the clear explanation; the education is
> appreciated.
> 
> >The
> > ProxyPassReverseCookieDomain and related directives also need to be at
> > considered, depending upon how much rewriting is done.
> 
> Well you've pointed me in the direction of the right things to study,
> but if I could prevail upon you to consider briefly aloud the best
> configuration of these directives in the fastcgi setup I've got going,
> I'd certainly be much obliged.

Looks like you won't need anything other than ProxyReversePass in the
setup you described. Rewriting the cookie domain and paths is necessary
if the external server is handing things off to an entirely different
namespace (in the DNS sense) or different paths. For example, if you're
reverse proxying for some portion of a DMZ with different internal
hostnames and an internal DNS server. In that case, you'd need to
rewrite cookie domains and, possibly paths (you're mapping external "/"
to internal "/", but sometimes paths might get rewritten as well). Your
setup, which is more or less a simple pass-through to a different
server, doesn't need this fanciness.

(By the way, if you ever do need those directives and omit them, you'll
find out the first time a cookie is used for something like logging in,
since it will appear to never have been set.)

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



Built-in Template Reference in Admin

2009-01-19 Thread Kerr

Hi all, I'm reading through the Django book online and am currently on
chapter 10.  http://djangobook.com/en/1.0/chapter10/

Near the end it mentions a built-in template reference available from
the admin interface, which contains info for all tags and filters
available for a given site.  In particular, the book states:

"Django’s admin interface includes a complete reference of all
template tags and filters available for a given site. It’s designed to
be a tool that Django programmers give to template developers. To see
it, go to the admin interface and click the Documentation link at the
upper right of the page."

I've enabled and am using the admin interface, but I don't see any
mention of 'Documentation' on the admin pages.  I viewed the source
just to see if something may be hidden and still found nothing.  I
understand that the online book was written for 0.96, so I looked at
the newest iteration of the book and it only has chapters 1-3 posted.
Am I missing something related to this built-in reference?

Thanks!
Kerr

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



Multiple images in form

2009-01-19 Thread DragonSlayre

Hi,

I've seen some posts from a while back, but didn't find any real
solution when searching to find out how to put multiple images (or any
field for that matter) into a form (mainly a  ModelForm)

Basically what I want to have is a form that has a one to many
relationship from a post to images, and to allow 5 images to be
displayed on the form.

Any simple way of doing this?

If not, any other ways that people can think of/have done?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread csingley


On Jan 19, 9:05 pm, Malcolm Tredinnick 
wrote:
> If the web server handling the Django requests is not the external web
> server, but is proxied for by some other server (e.g. Apache facing the
> outside world, passing off requests to a particular URL prefix to some
> other webserver that is doing the Django work), it might be that the
> internal connection between external web server and django-handling
> webserver is only HTTP, not HTTPS. In that case, Django thinks the
> request is an HTTP request and constructs the absolute URL
> appropriately.
>
> This situation isn't uncommon when using fastcgi, for example.

Yes, that's just what I've got set up - lighttpd with Apache front end
via fastcgi.

I configured Apache with "ProxyPass / http://127.0.0.1:${LIGHTTPD_PORT}";...
so come to think of it, it's not surprising that lighttpd is unaware
of an SSL connection that doesn't terminate upon it.

>
> In that sort of situation, it is the responsibility of the external
> webserver to rewrite any outgoing URLs correctly for the external world.
> Thus, it should know that it is converting an incoming HTTPS request to
> an HTTP request and thus convert any URLs for the local hostname back
> again before replying. In Apache, for example, this is often done with
> the ProxyPassReverse directive in the mod_proxy module.

The gentleman wins a large stuffed bear!  I cleverly neglected to
configure the ProxyPassReverse directive... as I said, I'm not the
sharpest knife in the drawer.  Rectifying this clears up the problem.

Thanks very much for the clear explanation; the education is
appreciated.

>The
> ProxyPassReverseCookieDomain and related directives also need to be at
> considered, depending upon how much rewriting is done.

Well you've pointed me in the direction of the right things to study,
but if I could prevail upon you to consider briefly aloud the best
configuration of these directives in the fastcgi setup I've got going,
I'd certainly be much obliged.

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



Re: model Admin inner class and admin.autodiscover()

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 18:14 -0800, Elyézer Mendes Rezende wrote:
> Hi, I'm using django 1.0.2 final, and for a test I setted the admin
> site configuration in the urls.py and used the Admin inner class like
> this:
> 
> class MyModel(...):
> ...
> class Admin():
> pass
> 
> And then my model is registered in the admin site.

Then you're doing something else in addition to this. Trying that on a
clean project (with the admin set up correctly) does nothing in the
admin interface.

Don't do that. It's not the way to use admin.

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



model Admin inner class and admin.autodiscover()

2009-01-19 Thread Elyézer Mendes Rezende

Hi, I'm using django 1.0.2 final, and for a test I setted the admin
site configuration in the urls.py and used the Admin inner class like
this:

class MyModel(...):
...
class Admin():
pass

And then my model is registered in the admin site.

But I see that to use an admin.py file and use the admin.site.register
(...) method and class definition in that file, and I use it.

Have someone tested this too? Worked?

PS.: it's not  doubt, but curiosity

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 18:42 -0800, csingley wrote:
> I've got a Django project set up behind an Apache SSL listener on port
> 443.  Unfortunately, this seems to break HTTP redirects.
> 
> For example, I have one view like this:
> """
> @login_required
> def home(request):
> return HttpResponseRedirect('/user/%s/' % request.user)
> """
> 
> When a user hits this view, HTTP request/response headers go like
> this:
> """
> https://www.${DOMAIN}.com/user/home/
> 
> GET /user/home/ HTTP/1.1
> Host: www.${DOMAIN}.com:443
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/
> 2009011218 Gentoo Firefox/3.0.5
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
> *;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Cookie: sessionid=e81f501da88277eb901df1aa3d3aa454
> 
> HTTP/1.x 302 Found
> Date: Mon, 19 Jan 2009 23:37:18 GMT
> Server: JWS 1.3
> Served-By: Joyent
> Vary: Cookie,Accept-Encoding
> Content-Type: text/html; charset=utf-8
> Location: http://www.${DOMAIN}.com:443/user/${USER}/
> Via: 1.1 ${DOMAIN}.com
> Content-Encoding: gzip
> Content-Length: 20
> Connection: close
> """
> 
> Now, all the other browsers I've tried seem to be smart enough to
> guess that if it's port 443, then maybe they should try SSL, 

Which means all the other browsers you tried are broken. If the URL says
the schema is "http", that's what they should be using.

> but for
> some reason Firefox gets its panties all in a bunch, sits down in a
> huff, and throws this error:
> """
> Bad Request

Correctly so, too.

So the solution here is going to depend a bit upon what your particular
setup is, and this kind of stuff is always very hard to debug without
specific knowledge and a lot of time. If your hosting provider has
support forums, that could well be a good place to search for clues,
since it's not unlikely somebody will have come across this problem
before. Here's the general background...

When you return something like HttpResponseRedirect("/foo/bar") from
Django, it has to turn that into an absolute URL, since Location headers
must be absolute, not relative. Part of an absolute URL is the schema
(the "http://"; or "https://"; part). Django works that out by looking at
the incoming request. See django/http/__init__.py in the
HttpRequest.build_absolute_uri() method for the details.

If the web server handling the Django requests is not the external web
server, but is proxied for by some other server (e.g. Apache facing the
outside world, passing off requests to a particular URL prefix to some
other webserver that is doing the Django work), it might be that the
internal connection between external web server and django-handling
webserver is only HTTP, not HTTPS. In that case, Django thinks the
request is an HTTP request and constructs the absolute URL
appropriately.

This situation isn't uncommon when using fastcgi, for example.

In that sort of situation, it is the responsibility of the external
webserver to rewrite any outgoing URLs correctly for the external world.
Thus, it should know that it is converting an incoming HTTPS request to
an HTTP request and thus convert any URLs for the local hostname back
again before replying. In Apache, for example, this is often done with
the ProxyPassReverse directive in the mod_proxy module. The
ProxyPassReverseCookieDomain and related directives also need to be at
considered, depending upon how much rewriting is done.

Now, all of this might have absolutely no bearing on your situation. I
don't know. I don't know the details of how your setup at Joyent is
configured. But it looks a lot like the request is reaching the server
handling your Django requests as an HTTP request, in which case, Django
is doing the right thing, as is Firefox, and the problem then reduces to
working out why an incoming HTTPS request is being converted to an HTTP
request. It's not inconceivable that for some reason the
HttpRequest.is_secure() method isn't returning the right thing,
although, again, that would suggest a bug in the WSGI wrapper that
you're using (most likely).

That should at least give you some ideas about how to start tracking
down the root cause of the problem. Work out why the incoming HTTPS
request looks like HTTP once it reaches Django. If it's converted by
some reverse proxy server (e.g. an external facing webserver), that
server is must be configured to do the reverse conversion for outgoing
requests as well. If it's something else, well... you'd need to work out
what it is, then we can start investigating possible solutions.

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

Re: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Aaron Lee
Yes avatar.image.url works, thanks again. -Aaron

On Mon, Jan 19, 2009 at 5:17 PM, creecode  wrote:

>
> I think you may be correct on that my tip was incorrect.  Forget what
> I said! :-)
>
> Have you tried getting the url like avatar.image.url?  I use a line
> like this in some of my code that uses S3Storage and it works.
>
> image_url = my_model_instance.image.url.replace ( ':80', '' )
>
> On Jan 19, 4:01 pm, "Aaron Lee"  wrote:
> > Thanks for your tip, I believe your suggestion will end up having my.jpg
> > under
> > my-bucket-name.s3.amazonaws.com.s3.amazonaws.com/userprofile/my.jpg
> >
> > I think the AWS_STORAGE_BUCKET_NAME should just be userprofile
>
> > So how do you access the image, do you manually construct the URL?
> >
>

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



HttpResponseRedirect with https screws up Firefox?

2009-01-19 Thread csingley

I've got a Django project set up behind an Apache SSL listener on port
443.  Unfortunately, this seems to break HTTP redirects.

For example, I have one view like this:
"""
@login_required
def home(request):
return HttpResponseRedirect('/user/%s/' % request.user)
"""

When a user hits this view, HTTP request/response headers go like
this:
"""
https://www.${DOMAIN}.com/user/home/

GET /user/home/ HTTP/1.1
Host: www.${DOMAIN}.com:443
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/
2009011218 Gentoo Firefox/3.0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: sessionid=e81f501da88277eb901df1aa3d3aa454

HTTP/1.x 302 Found
Date: Mon, 19 Jan 2009 23:37:18 GMT
Server: JWS 1.3
Served-By: Joyent
Vary: Cookie,Accept-Encoding
Content-Type: text/html; charset=utf-8
Location: http://www.${DOMAIN}.com:443/user/${USER}/
Via: 1.1 ${DOMAIN}.com
Content-Encoding: gzip
Content-Length: 20
Connection: close
"""

Now, all the other browsers I've tried seem to be smart enough to
guess that if it's port 443, then maybe they should try SSL, but for
some reason Firefox gets its panties all in a bunch, sits down in a
huff, and throws this error:
"""
Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

Hint: https://${DOMAIN}.com/
"""

I certainly don't want to hard-code the domain name into my view
above.  I'm trying to pick through the source in django.http, but I'm
not the sharpest knife in the drawer.  Is it true that Django is
constructing HttpResponseRedirects with http:// URLs rather than https://
?  Is there someway I can change this behavior, or troubleshoot the
actual source of the problem, or another way to accomplish my goal?

TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-19 Thread Malcolm Tredinnick

On Tue, 2009-01-20 at 02:07 +, Hans Fangohr wrote:
[...]
> However, in the template files, I extend my base.html which makes use  
> of the request object (basically checking whether the request has as  
> authenticated used and changing the html depending on this).
> 
> It appears that the request object is not available in registration/ 
> password_change_form.html when called from the view  
> django.contrib.auth.views.password_change.

You might well be approachign this the wrong way. That particular view
uses a RequestContext as the context instance passed to the template.
Which means, unless you have changed the default context processors, you
will have a "user" variable in the context, representing the current
user. That's the common approach to accessing things like the required
user.

Refer to http://docs.djangoproject.com/en/dev/ref/templates/api/#id1 for
details.

If, for some reason, you really, really, really need the full request
object to be available there and, for some reason, writing your own
version of the view isn't an option (it's less than 12 lines long;
maintaining your own version won't be too onerous), you could write your
own context processor that included the full "request" instance in the
context. The simplest approach, though, would be to switch to using
"user", rather than "request" as the thing you check.

Regards,
Malcolm

> 
> Here is the question: Is there a (simple?) way of feeding that request  
> object somehow into the view so that it can be used in the  
> registration/password_change_form.html?
> 
> Many thanks for any hints in advance,
> 
> Hans
> 
> 
> 
> 
> 
> 
> 
> > 
> 


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



Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-19 Thread Hans Fangohr

Dear all,

a beginner's question: I have added these entries into a django  
project in the urls.py:

   (r'^accounts/password_change/$',  
django.contrib.auth.views.password_change),
   (r'^accounts/password_change_done/$',  
django.contrib.auth.views.password_change_done),

and I have provided customised versions of the template files that  
these views use (i.e. registration/password_change_form.html and  
registration/password_change_done.html).

This is all working nicely :), well done Django developers.

However, in the template files, I extend my base.html which makes use  
of the request object (basically checking whether the request has as  
authenticated used and changing the html depending on this).

It appears that the request object is not available in registration/ 
password_change_form.html when called from the view  
django.contrib.auth.views.password_change.

Here is the question: Is there a (simple?) way of feeding that request  
object somehow into the view so that it can be used in the  
registration/password_change_form.html?

Many thanks for any hints in advance,

Hans







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Suspicious Operation/ filestorage problem

2009-01-19 Thread bax...@gretschpages.com



On Jan 19, 1:42 pm, Andy Mckay  wrote:
> If i remember, it's because there's a / at the beginning, you probably  
> want a relative path.

OK, where's it picking up the / then?

I've got:
if self.avatar is None:
 self.avatar = "img/avatars/default.gif"

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



Re: proper way to use S3Storage and Django ImageField

2009-01-19 Thread creecode

I think you may be correct on that my tip was incorrect.  Forget what
I said! :-)

Have you tried getting the url like avatar.image.url?  I use a line
like this in some of my code that uses S3Storage and it works.

image_url = my_model_instance.image.url.replace ( ':80', '' )

On Jan 19, 4:01 pm, "Aaron Lee"  wrote:
> Thanks for your tip, I believe your suggestion will end up having my.jpg
> under
> my-bucket-name.s3.amazonaws.com.s3.amazonaws.com/userprofile/my.jpg
>
> I think the AWS_STORAGE_BUCKET_NAME should just be userprofile

> So how do you access the image, do you manually construct the URL?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Composite Indexing

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 16:55 -0800, Andrew Fong wrote:
> I'm using contrib.contenttypes and have added the following to my
> model:
> 
> content_type = models.ForeignKey(ContentType)
> object_id = models.PositiveIntegerField()
> content_object = generic.GenericForeignKey()
> 
> When examining the DB (I'm using MySQL), I find that content_type is
> indexed but object_id is not. I was going to just index object_id, but
> it makes more sense to put a composite index on both content_type and
> object_id together. Unfortunately, I have no idea how to do this
> without writing raw SQL.

Right. So the solution is to use raw SQL. Django is not intended to be a
complete replacement for interacting with the database via SQL. That's
why connection.cursor() is exposed, for example.

It's not entirely clear why we aren't using a multi-column index there,
however, beyond the fact that it might just have been overlooked. I'll
talk to Jacob about it at some point (since he wrote that stuff). If we
did that, it should be in the order (content_type, object_id), since
querying on object_id without content_type doesn't make sense, whereas
the reverse possibly does (although will also be fairly uncommon).

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



Composite Indexing

2009-01-19 Thread Andrew Fong

I'm using contrib.contenttypes and have added the following to my
model:

content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()

When examining the DB (I'm using MySQL), I find that content_type is
indexed but object_id is not. I was going to just index object_id, but
it makes more sense to put a composite index on both content_type and
object_id together. Unfortunately, I have no idea how to do this
without writing raw SQL. I googled around but the only stuff I could
find is on primary composite keys and the unique_together constraint.
However, I don't want this composite index to be a primary key, and I
don't want it to be unique. Am I missing something here?

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

2009-01-19 Thread creecode

Hello NoviceSortOf,

You may want to check out this Django documentation <
http://docs.djangoproject.com/en/dev/ref/settings/#auth-profile-module
> and < http://docs.djangoproject.com/en/dev/topics/auth/ > on
AUTH_PROFILE_MODULE which may clear up your confusion.  Registration
doesn't use AUTH_PROFILE_MODULE directly AFAICT.  The registration
docs just mention it as something you might want to take advantage of
and how using it relates to using registration.

Toodle-lo
creecode
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread David Larlet


Le 20 janv. 09 à 01:48, Aaron Lee a écrit :

> Thanks David, but it seems awkward to call
>
> avatar.image.storage.url(str(avatar.image))
>
> to retrieve the URL for an ImageField.
> Do you have a better way?

avatar.image.url should work (without parenthesis, that's a property).
I propose to continue the discussion as private, I don't want to flood  
that list with custom apps.

David

PS: note to self, add more examples in documentation...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Aaron Lee
Thanks David, but it seems awkward to call

avatar.image.storage.url(str(avatar.image))

to retrieve the URL for an ImageField.
Do you have a better way?

-Aaron


On Mon, Jan 19, 2009 at 4:02 PM, David Larlet  wrote:

>
>
> Le 19 janv. 09 à 22:53, Aaron Lee a écrit :
> >
> > But I am still getting the exception saying the backend doesn't
> > support absolute paths.
> > In django/db/models/fields/files.py line 52 _get_path
> >   return self.storage.path(self.name)
> >
> > and my self.name is userprofile/cs1.jpg
> >
> > Any suggestions?
>
> Hi Aaron,
>
> Sorry for my late answer, I was on holidays, what about
> instance.url()? (that's the recommended way to do, .path() is for
> local storages)
>
> Regards,
> David
>
>
>
> >
>

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



Re: Best practise for using settings in templates

2009-01-19 Thread Fergus

Or you can set up a custom template tag that returns settings values
if you only want the settings on particular pages, and don't want to
add boilerplate to each view, or have the overhead of a context
processor.


On Jan 18, 12:25 pm, phoebebright  wrote:
> Thanks - learning more every day!
>
> On Jan 18, 11:37 am, Malcolm Tredinnick 
> wrote:
>
> > On Sun, 2009-01-18 at 03:26 -0800, phoebebright wrote:
> > > What is best practise if you want to use a variable defined in
> > > settings.py in a template?
> > > Pass it in via the view or call it directly in the template?
>
> > Since you can't access it directly in a template, that leaves only the
> > former option ("best practice" is not to attempt the impossible). Pass
> > it in. If you find yourself needing a particular setting regularly, you
> > could set up a context processor to populate context with the value(s)
> > you require, just like the media context processor does
> > (http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c...)
>
> > 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: Raw SQL parameters

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 17:49 +0100, Matias Surdi wrote:
> Hi,
> 
> 
> I'm trying to run a sql query with parameters taken from a dict, here is 
> the relevant part of the code:
>   query = "select * from table where name='%(name)s'"
>   parameters = {'name':'valueofname'}
>  cursor = connection.cursor()
>  data = cursor.execute(query,parameters)
> 
> 
> The error I get is:
> 
> TypeError: format requires a mapping
> 
> 
> But, as far as I know (from PEP249) this should be possible.

Just to be accurate, PEP 249 says that a paramstyle of "pyformat" is one
possible value, which would permit the above sort of query. It does not
say that every conforming database wrapper is required to support it.
Although the PEP recommends supporting "numeric", "named" or pyformat"
styles of parameter markers, historically and practically, most database
wrappers have supported "format", although SQLite (and some other
databases that don't have backends in Django's core, although the exact
names escape me now) only supports "qmark".

Since you note later in the thread that you're using SQLite, that is the
cause of the confusion here. I don't think there's any bug.

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: Filter model and retrieve associated model/objects at same time

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 12:27 -0800, sico wrote:
[...]
> I haven't checked but assuming this is going to execute 2 sql commands
> for each row returned by the first query not good!!
> Is there a way to tell django/python that I want to retrieve the
> related data from the other 2 models before looping through the
> queryset so it can figure out to do the necessary joins??

Have you looked at select_related()?

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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread David Larlet


Le 19 janv. 09 à 22:53, Aaron Lee a écrit :
>
> But I am still getting the exception saying the backend doesn't  
> support absolute paths.
> In django/db/models/fields/files.py line 52 _get_path
>   return self.storage.path(self.name)
>
> and my self.name is userprofile/cs1.jpg
>
> Any suggestions?

Hi Aaron,

Sorry for my late answer, I was on holidays, what about  
instance.url()? (that's the recommended way to do, .path() is for  
local storages)

Regards,
David



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



Re: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Aaron Lee
Thanks for your tip, I believe your suggestion will end up having my.jpg
under
my-bucket-name.s3.amazonaws.com.s3.amazonaws.com/userprofile/my.jpg

I think the AWS_STORAGE_BUCKET_NAME should just be userprofile

With your tip I think I narrow down the issue. The old way of the image
being accessed was

image = Image.open(avatar.image.path)

But S3Storage doesn't define the _path function and hence the absolute path
exception.
Not sure why S3StorageFile doesn't have the path() function either.

So how do you access the image, do you manually construct the URL?

-Aaron

On Mon, Jan 19, 2009 at 3:11 PM, creecode  wrote:

>
> Hey Aaron,
>
> I think part of your problem is that AWS_STORAGE_BUCKET_NAME is not
> properly specified.  It think it needs to be something like my-bucket-
> name.s3.amazonaws.com.  Based on your settings then you should find
> your images end up at http:my-bucket-name.s3.amazonaws.com/
> userprofile/ .  You
> may need to change the permissions on your bucket
> and "directories" so that you can access the images via a url.  I
> found S3 Organizer a plug-in for FireFox useful for this.
>
> Toodle-l
> creecode
>
> On Jan 19, 1:53 pm, "Aaron Lee"  wrote:
>
> > AWS_STORAGE_BUCKET_NAME='userprofile'
> >
>

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

2009-01-19 Thread David Larlet

Chris,

It seems that oauth_token argument is missing from your response. Do  
you still have errors with your code?

Do not hesitate to contact me directly if that's the case, I do not  
want to spam this mailing-list with custom apps support.

Regards,
David

Le 14 janv. 09 à 05:49, Chris a écrit :

>
> Well I plugged in my variables into the example client and it still
> seems to break on the same segment:
> token = client.fetch_request_token(oauth_request)
>
> I am using code from this repository to handle the server sided
> portion:
> http://code.larlet.fr/django-oauth/
> Perhaps there is an issue with this library.  I will look into this.
>
> example documentation:
> http://code.larlet.fr/doc/django-oauth-provider.html
> This example seems to do things slightly different.
>
>
>
> Chris
>
>
>
> On Jan 13, 7:29 pm, Malcolm Tredinnick 
> wrote:
>> On Tue, 2009-01-13 at 18:54 -0800, Chris wrote:
>>> Hello,
>>
>>> I have been using django-oauth and am getting the below error using
>>> this codehttp://dpaste.com/108808/
>>
>>> I get this when running the dpaste code in the python shell.
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>>   File "", line 7, in get_unauthorised_request_token
>>>   File "/usr/lib/python2.5/site-packages/oauth.py", line 70, in
>>> from_string
>>> key = params['oauth_token'][0]
>>> KeyError: 'oauth_token'
>>
>>> so when I make a request to /oauth/request_token/, it initializes  
>>> the
>>> oauth classes and methods using:
>>> oauth_server, oauth_request = initialize_server_request(request)
>>
>>> next, this call which seems to be where it breaks:
>>> token = oauth_server.fetch_request_token(oauth_request)
>>
>>> so the oauth_request does not have the oauth_token key (as the error
>>> describes) which after traversing through the oauth library and the
>>> django-oauth app I do not see where an oauth_token is being  
>>> generated
>>> and added to the oauth_request.
>>
>> It looks like the server you're talking to might not be returning the
>> right data. The data you're getting back from the fetch_response()  
>> call
>> should contain information that can be passed to from_string(). Your
>> fetch_response() isn't too different from the sample client
>> implementation at [1], so you might want to check out the minor
>> difference there, to verify you've omitted it intentionally. Then  
>> check
>> out whatever is printed in fetch_response() to see why it isn't what
>> you're expecting (you're printing that information out already).
>>
>> [1]http://oauth.googlecode.com/svn/code/python/oauth/example/ 
>> client.py
>>
>> If I understand the code correctly, the key that from_string() is
>> looking for is the token and secret that the oauth server returns  
>> to you
>> (the client) that is your (temporary) authorisation to access some  
>> data
>> on the server. So it's server-side generated.
>>
>> 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread creecode

Hey Aaron,

I think part of your problem is that AWS_STORAGE_BUCKET_NAME is not
properly specified.  It think it needs to be something like my-bucket-
name.s3.amazonaws.com.  Based on your settings then you should find
your images end up at http:my-bucket-name.s3.amazonaws.com/
userprofile/.  You may need to change the permissions on your bucket
and "directories" so that you can access the images via a url.  I
found S3 Organizer a plug-in for FireFox useful for this.

Toodle-l
creecode

On Jan 19, 1:53 pm, "Aaron Lee"  wrote:

> AWS_STORAGE_BUCKET_NAME='userprofile'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Deployment of apps with 3rd party code

2009-01-19 Thread Ariel Mauricio Nunez Gomez
>
> What approaches have been popular for deploying projects and applications
> with 3rd party python modules (code usually found in site-packages).  Should
> the packages always be installed when possible or is it acceptable within
> the community to have a "lib" directory within a application or project that
> will contain 3rd party libraries.
>
> e.g. from myapp.lib.boto.s3 import Connection
>
I think it would be better to do from 'boto.s3 import Connection'


> This would have the benefit of maintaining a specific version of the
> library across servers and decrease requirements during deployment, but I
> not aware of what downsides there might be.
>

I would consider this a good reference:
http://svn.pinaxproject.com/pinax/trunk/

Take a special look at the modifications done to manage.py

Ariel.

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

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 2:06 PM, Matias Surdi  > wrote:
> 
> Yes, maybe it's just a problem with sqlite, which is te backend I'm
> using.I'll try with mysql later.
> 
> Is this a bug? should it be reported as a ticket?
> 
> 
> I see you opened ticket #10070, which is fine because I don't know the 
> answer to whether it is a bug that some of the backends do not support 
> this style of parameter passing.  Django apparently doesn't use it 
> internally, nor document support for it 
> (http://docs.djangoproject.com/en/dev/topics/db/sql/ doesn't mention it) 
> so it may be permissible variation in the backends, I don't know.  
> Hopefully someone who knows more than I will respond in that ticket.
> 
> Karen
> 
> > 


Many thanks for your help.


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



Re: Invalid block tag: "get_comment_count"

2009-01-19 Thread Briel

You should try playing around with the tags, trying to load comments
different places trying some of the other comment tags to see what
happens ect.
Also are you using the block tags? what block tags do you have where
have you placed them in relation to your code?

On 19 Jan., 22:16, Florian Lindner  wrote:
> Am 19.01.2009 um 22:04 schrieb Briel:
>
> > It's hard to say what's going wrong with the code you provided, but I
> > can say a few things. Since you don't get an error from {% load
> > comments %}, there should be no problems with the installation.
> > However, you might not actually run the command in the template, it
> > could be that you are writing it over with an extend tag. The error
> > hints that get_comment_count is an invalid tag, so you should test if
> > comments is loaded probably in your template.
> > Try loading comments directly above your tag and see what happens and
> > take it from there.
>
> Hi!
>
> The complete code is:
>
> {% load comments % }
>
> 
> {% get_comment_count for object as comment_count %}
>
> So I don't there is much that could have introduced an error. I extent  
> an base template but it doesn't make any use of something called  
> comment actually it does not use any non-trivial Django markup.
>
> How can I test the comments is loaded properly?
>
> Thanks,
>
> Florian
>
>
>
> > -Briel
>
> > On 19 Jan., 21:01, Florian Lindner  wrote:
> >> Hello,
>
> >> I'm trying to use the comment framework from Django 1.0.2.
>
> >> I've followed all the steps 
> >> inhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
> >>   (added it to installed apps, added to urls.py and loaded in the
> >> template: {% load comments % }) but I get:
>
> >> TemplateSyntaxError at /blog/1/
> >> Invalid block tag: 'get_comment_count'
>
> >> from:
>
> >> {% get_comment_count for object as comment_count %}
>
> >> object has just been created so probably no comment yet attached.
>
> >> What could have went wrong there?
>
> >> Thanks!
>
> >> Florian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Aaron Lee
Yes and yes,
here are my settings in settings.py

# Storage Settings
DEFAULT_FILE_STORAGE = 'libs.storages.S3Storage.S3Storage'
AWS_ACCESS_KEY_ID='xxx'
AWS_SECRET_ACCESS_KEY='xxx'
AWS_STORAGE_BUCKET_NAME='userprofile'
from S3 import CallingFormat
AWS_CALLING_FORMAT=CallingFormat.SUBDOMAIN
AWS_HEADERS = {
'Expires': 'Sat, 10 Jan 2049 00:00:00 GMT',
'Cache-Control': 'max-age=86400',
}
#

and I also verified that I have a bucket called "userprofile" in my Amazon
account.
In the DB I have
mysql> select * from userprofile_avatar;
++-+-+-+---+
| id | image   | user_id | date| valid |
++-+-+-+---+
|  4 | userprofile/cs1.jpg |   2 | 2009-01-19 13:46:12 | 0 |
++-+-+-+---+

But I am still getting the exception saying the backend doesn't support
absolute paths.
In django/db/models/fields/files.py line 52 _get_path
  return self.storage.path(self.name)

and my self.name is userprofile/cs1.jpg

Any suggestions?
-Aaron










On Mon, Jan 19, 2009 at 4:22 PM, Merrick  wrote:

>
> I am using S3Storage with an imagefield successfully. It sounds like
> you have not specified the storage engine and keys etc... in
> settings.py as creecode pointed out.
>
> I recall testing that the directory will be created on the fly if it
> does not exist.
>
> On Jan 19, 12:40 pm, creecode  wrote:
> > Hello Aaron,
> >
> > I can confirm that it can work.  I'm using it but I don't know enough
> > to diagnose your problem.
> >
> > Have you created the userprofile "directory" in your S3 bucket?
> >
> > Have you added the following to your settings.py?
> >
> > DEFAULT_FILE_STORAGE = 'S3Storage.S3Storage'
> >
> > AWS_ACCESS_KEY_ID
> > AWS_SECRET_ACCESS_KEY
> > AWS_STORAGE_BUCKET_NAME
> > AWS_CALLING_FORMAT
> >
> > Have you installed any software S3Storage depends on?
> >
> > On Jan 19, 8:02 am, "Aaron Lee"  wrote:
> >
> > > So I guess S3Storage doesn't work with ImageField? Can anyone confirm
> that?
> >
> > Toodle-l.
> > creecode
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Problems with (Model)ChoiceField and the like

2009-01-19 Thread James Smagala

I hacked my way through my problem this weekend, and I posted a
snippet about it here.

For anyone having problems with complex dynamic formsets, check check
out Malcolm Tredinnick's blog:

http://www.pointy-stick.com/blog/2008/01/06/django-tip-complex-forms/

And additionally, take a look at my attempts to turn his solution into
a formset:

http://www.djangosnippets.org/snippets/1290/

Hope that is helpful to someone out there.

J

On Jan 14, 7:03 pm, James Smagala  wrote:
> Hey All,
>
> There is a discussion here about building dynamic form select fields
> using __init__ on the form.  This, by itself, is not hard.
>
> http://groups.google.com/group/django-users/browse_thread/thread/98bd...
>
> Problem:  I have a formset that needs each form in it to be created in
> this dynamic sort of manner.
>
> Possible solutions:
>
> - Create the formset containing no forms, add them individually, and
> update the management form.  I had this mostly implemented, but I
> don't know how to actually update the values on the management form.
> Where do they live?
>
> - Figure out some tricky syntax that lets me pass both the queryset
> for a modelchoicefield (and an initial choice for said field) to a
> form.  Also figure out how to pass it though a formset to correctly
> init all those dynamic forms.  Not having much luck here.
>
> - Post about it, and get told I'm doing it all wrong.  Suggestions are
> welcome!
>
> Please help!
>
> 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: POST sub dictionaries

2009-01-19 Thread Briel

You should really read the django docs:
http://docs.djangoproject.com/en/dev/ref/request-response/

In your first case, the latter value will overwrite the first value,
so:
request.POST['test[]'] = 1 or POST = {'test[]': 1}

In your second case, you will just have one value:
request.POST['test[key]'] = 1 or POST = {'test[key]': 1}

You can't write objects into the name of the html input tag. Whatever
you write will be just a name. You can instead send objects like
lists, dictionaries of whatever you like in posts, but you don't want
people to input those, unless it's into a form that you validate
first. If you want to know about forms in django read about it in the
docs
http://docs.djangoproject.com/en/dev/topics/forms/

-Briel


On 19 Jan., 20:35, "Vinicius Mendes"  wrote:
> Is there in django something like the PHP POST subarrays?
>
> For example, if i do this in my form:
>
> 
> 
>
> and submit it, i will have the following data structure in my PHP POST:
>
> $_POST = array(
>     'test' => array(
>         0 => 0,
>         1 => 1
>     )
> )
>
> In django, i think it can turn into:
>
> request.POST = {
>     'test': (0,1)
>
> }
>
> What means it is a dictionary with a tuple as the value of the 'test' key.
>
> Another case is this:
>
> 
>
> Whet gives this in PHP:
>
> $_POST = array(
>     'test' => array(
>         'key' => 1
>     )
> )
>
> What means the following in python:
>
> request.POST = {
>     'test': {
>         'key': 1
>     }
>
> }
>
> Is there anything like this in django? I think it can make formsets much
> more easier to use, and eliminates the needing of the management_form.
>
> 
>
> Vinícius Mendes
> Engenheiro de Computação
> Meio Código - A peça que faltava para o seu código!
> URLhttp://www.meiocodigo.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Merrick

I am using S3Storage with an imagefield successfully. It sounds like
you have not specified the storage engine and keys etc... in
settings.py as creecode pointed out.

I recall testing that the directory will be created on the fly if it
does not exist.

On Jan 19, 12:40 pm, creecode  wrote:
> Hello Aaron,
>
> I can confirm that it can work.  I'm using it but I don't know enough
> to diagnose your problem.
>
> Have you created the userprofile "directory" in your S3 bucket?
>
> Have you added the following to your settings.py?
>
> DEFAULT_FILE_STORAGE = 'S3Storage.S3Storage'
>
> AWS_ACCESS_KEY_ID
> AWS_SECRET_ACCESS_KEY
> AWS_STORAGE_BUCKET_NAME
> AWS_CALLING_FORMAT
>
> Have you installed any software S3Storage depends on?
>
> On Jan 19, 8:02 am, "Aaron Lee"  wrote:
>
> > So I guess S3Storage doesn't work with ImageField? Can anyone confirm that?
>
> Toodle-l.
> creecode
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread bruno desthuilliers

On 19 jan, 18:04, "Thiago F. Crepaldi"  wrote:

Absolutely not an answer to your question, but...

> below is the code required. I hope you can help me =)
>
#*
> #  searchFeature
 
#*
> def searchFeature(request, view = None):
> if request.method == 'POST':
> form = SearchFeatureForm(request.POST)
> if form.is_valid():
> # Perform the query
>
> ftrQuery = Feature.objects.all().order_by('featureId',
> 'pk')

Since your going to filter this out, starting by querying all is
useless (thanks to querysets being lazy, it's at least _only_ useless.

Remember that Django has Q objects for building complex queries, and
that you can just collect Q objects in a list, then "or" or (like in
this case) "and" them together in just one pass.

>
> # Remove empty fields and start filtering
> if request.POST.__getitem__('featureId') != "":

First point : you should never directly access __magic_methods__ in
Python - they are here as implementation for operators. In this case,
you want:

   if request.POST.get('featureId', '') != '':

Second point: since empty strings eval to false in a boolean context,
you don't have to explicitely compare them with the empty string. IOW:

  if request.POST.get('featureId, ''):

> ftrQuery = ftrQuery.filter(featureId__contains =
> request.POST.__getitem__('featureId')).distinct()


Third point : you're doing the same access twice. Better to do it just
once:

featureId = request.POST.get('featureId, '')
if featureId:
 # code here

While we're at it, attribute lookup is a somewhat costly operation in
Python, specially when the attribute resolves to a method. So if
you're going to heavily use the same method of the same object, it's
better to alias it to a local name:

 get_from_post = request.POST.get

 featureId = get_from_post('featureId, '')
 if featureId:
 # code here


While we're at it : your form object is supposed to give you access to
the validated (and possibly converted) data extracted from the
request. Is there any reason to not use this feature ?

Next point : you can pass dict objects to Queryset.filter(), (or to Q
objects) using the ** notation (cf the section of the official Python
tutorial about functions and named / keyword arguments). So you could
greatly simplify you code:

filters = [
   # fieldname, lookup
   ("featureId", "featureId__contains"),
   ("name", "name__icontains")
   ("pf", "platform"),
   ("state", "state"),
   ("db", "drumbeat__pk"),
   # etc
   ]

queries = []
add_q = queries.append
for fieldname, lookup in filters:
value = get_from_post(fieldname, '')
if value:
add_q(Q(**{lookup:value}))


# now "and" the Q objects:
filters = reduce(lambda q1, q1 : q1 & q2, filters)

# and do the query:
if filters:
queryset = Feature.objects.filter(filters)
else:
queryset = Feature.objects.all()

queryset = queryset.order_by('featureId', 'pk')

This can not apply to all your query construction (there are some
complex cases in it), but it should already help uncluttering it for
all the simple cases.

(snip)

> from datetime import date

Better to put import statements at the module's top-level.

> #Only way I could find to select with COUNT without
> writting the SQL code.

You might have a look at the example snippet for the 'extra' method of
querysets.



> if queryTeamSizeLow != '':
> for item in ftrQuery:
> if item.teammember_set.count() < int
> (queryTeamSizeLow):

Oh my. Pity this poor computer, and at least convert queryTeamSizeLow
to an int only once...


> ftrQuery = ftrQuery.exclude
> (featureId=item.featureId)
>
> if queryTeamSizeHigh != '':
> for item in ftrQuery:
> if item.teammember_set.count() > int
> (queryTeamSizeHigh):
> ftrQuery = ftrQuery.exclude
> (featureId=item.featureId)


Ok. Some things are better done building raw sql queries. Django's ORM
is here to help with the easy and boring 80%, not to replace SQL.

My 2 cents...

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

Deployment of apps with 3rd party code

2009-01-19 Thread Peter Manis
Hello,

What approaches have been popular for deploying projects and applications
with 3rd party python modules (code usually found in site-packages).  Should
the packages always be installed when possible or is it acceptable within
the community to have a "lib" directory within a application or project that
will contain 3rd party libraries.

e.g. from myapp.lib.boto.s3 import Connection

This would have the benefit of maintaining a specific version of the library
across servers and decrease requirements during deployment, but I not aware
of what downsides there might be.

Thanks,
-- 
Peter Manis

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

2009-01-19 Thread Florian Lindner


Am 19.01.2009 um 22:04 schrieb Briel:

> It's hard to say what's going wrong with the code you provided, but I
> can say a few things. Since you don't get an error from {% load
> comments %}, there should be no problems with the installation.
> However, you might not actually run the command in the template, it
> could be that you are writing it over with an extend tag. The error
> hints that get_comment_count is an invalid tag, so you should test if
> comments is loaded probably in your template.
> Try loading comments directly above your tag and see what happens and
> take it from there.

Hi!

The complete code is:

{% load comments % }


{% get_comment_count for object as comment_count %}

So I don't there is much that could have introduced an error. I extent  
an base template but it doesn't make any use of something called  
comment actually it does not use any non-trivial Django markup.

How can I test the comments is loaded properly?

Thanks,

Florian



>
>
> -Briel
>
> On 19 Jan., 21:01, Florian Lindner  wrote:
>> Hello,
>>
>> I'm trying to use the comment framework from Django 1.0.2.
>>
>> I've followed all the steps 
>> inhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
>>   (added it to installed apps, added to urls.py and loaded in the
>> template: {% load comments % }) but I get:
>>
>> TemplateSyntaxError at /blog/1/
>> Invalid block tag: 'get_comment_count'
>>
>> from:
>>
>> {% get_comment_count for object as comment_count %}
>>
>> object has just been created so probably no comment yet attached.
>>
>> What could have went wrong there?
>>
>> Thanks!
>>
>> Florian
> >


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

2009-01-19 Thread Briel

Hi

It's hard to say what's going wrong with the code you provided, but I
can say a few things. Since you don't get an error from {% load
comments %}, there should be no problems with the installation.
However, you might not actually run the command in the template, it
could be that you are writing it over with an extend tag. The error
hints that get_comment_count is an invalid tag, so you should test if
comments is loaded probably in your template.
Try loading comments directly above your tag and see what happens and
take it from there.

-Briel

On 19 Jan., 21:01, Florian Lindner  wrote:
> Hello,
>
> I'm trying to use the comment framework from Django 1.0.2.
>
> I've followed all the steps 
> inhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
>   (added it to installed apps, added to urls.py and loaded in the  
> template: {% load comments % }) but I get:
>
> TemplateSyntaxError at /blog/1/
> Invalid block tag: 'get_comment_count'
>
> from:
>
> {% get_comment_count for object as comment_count %}
>
> object has just been created so probably no comment yet attached.
>
> What could have went wrong there?
>
> Thanks!
>
> Florian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread creecode

Hello Aaron,

I can confirm that it can work.  I'm using it but I don't know enough
to diagnose your problem.

Have you created the userprofile "directory" in your S3 bucket?

Have you added the following to your settings.py?

DEFAULT_FILE_STORAGE = 'S3Storage.S3Storage'

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
AWS_CALLING_FORMAT

Have you installed any software S3Storage depends on?

On Jan 19, 8:02 am, "Aaron Lee"  wrote:
> So I guess S3Storage doesn't work with ImageField? Can anyone confirm that?

Toodle-l.
creecode
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Filter model and retrieve associated model/objects at same time

2009-01-19 Thread sico

btw... using 0.96 here...

On Jan 20, 9:27 am, sico  wrote:
> Hi,
>
> I'm filtering a model on some criteria... and based on the resultset I
> want to retrieve associated related models (all one-to-one
> relationships)
>
> Whats the most efficient way to do this without resorting to custom
> SQL?
>
> this is the best I can come up with:
>
> obj1s = MyModel1.filter(blah_blah=blah)
>
> data = []
> for obj1 in obj1s:
>     obj2 = MyModel2.get(pk=obj.pk)
>     obj3 = MyModel3.get(pk=obj.pk)
>     data.append({'obj1':obj1,
>                   'obj2':obj2,
>                   'obj3':obj3,
>                })
> return data
>
> I haven't checked but assuming this is going to execute 2 sql commands
> for each row returned by the first query not good!!
> Is there a way to tell django/python that I want to retrieve the
> related data from the other 2 models before looping through the
> queryset so it can figure out to do the necessary joins??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Filter model and retrieve associated model/objects at same time

2009-01-19 Thread sico

Hi,

I'm filtering a model on some criteria... and based on the resultset I
want to retrieve associated related models (all one-to-one
relationships)

Whats the most efficient way to do this without resorting to custom
SQL?

this is the best I can come up with:

obj1s = MyModel1.filter(blah_blah=blah)

data = []
for obj1 in obj1s:
obj2 = MyModel2.get(pk=obj.pk)
obj3 = MyModel3.get(pk=obj.pk)
data.append({'obj1':obj1,
  'obj2':obj2,
  'obj3':obj3,
   })
return data

I haven't checked but assuming this is going to execute 2 sql commands
for each row returned by the first query not good!!
Is there a way to tell django/python that I want to retrieve the
related data from the other 2 models before looping through the
queryset so it can figure out to do the necessary joins??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



ModelForm values.

2009-01-19 Thread tom.s.macken...@gmail.com

I want to create a form based on a model and inject data into it
manually. See below for implementation.

class Approval(models.Model):
company   = models.ForeignKey(Company)
product   = models.ForeignKey(Product)
approval_type = models.ForeignKey(Approval_Type, help_text='How
did you get your information?')
ingredient= models.ForeignKey(Ingredient,default=1)
pub_date  = models.DateTimeField
(default=datetime.datetime.now)
approved  = models.BooleanField()
url   = models.CharField(null=True, blank=True,
max_length=100)
comment   = models.CharField(null=True, blank=True,
max_length=200)
user  = models.ForeignKey(User)
show  = models.BooleanField(default=False)
show_pub_date = models.DateTimeField(null=True, blank=True)

class ApprovalForm(ModelForm):
class Meta:
model = Approval
fields =
('company','product','approval_type','approved','url','comment')

#Views.py

products = Product.objects.filter(company=company_id)
companies = Company.objects.filter(id=company_id)
types = Approval_Type.objects.all()

data = {'company': companies,
'product': products,
'approval_type': types,
'approved': False,
'url': 'www.someWebSite.com',
'comment': 'Enter Comment Here',}

form = ApprovalForm(data, initial={'company': company_id,
   'product':product_id})

My Expectations for the company and product content is:
1. I want all the companies injected into the form.
2. I only want the products that relate to the initial company that is
selected. (This is because in the template I want to list only the
products that relate to the current selected company via JQuery).

The only fields being assigned are the ones that are not multiple
choice ones (url is ok, comment, etc). How do I assign the data for
the company and product fields?

Any advise is welcome
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread NoviceSortOf

> I'm feeling a bit dense here.  What is it, exactly, that isn't working?
> What have you done, what did you expect, and what happens instead?
> AUTH_PROFILE_MODULE isn't fundamentally broken, so some specifics on what
> isn't working for you would help someone to help you fix whatever it is that
> isn't working.  But from all you've written I still have no idea what that
> is.

Karen:

Thanks for your patience, at least I'm driving and drilling towards a
clearer definition of the question.

I'll try getting more specific.

We can't determine how to populate the table specified in
AUTH_PROFILE_MODULE
with the user row during the registration process.

Inside of registration.models.py there is a class defined called
RegistrationManager with the methods create_inactive_user and
create_profile. Create_inactive user does what one would think that it
would.
The code in create_inactive_user explicit in telling you it is saving
the fields self, username, password & email.

create_profile on the otherhand although its method name is analogous
seems simply to
create an activation key, and there is way to determining how and
where it is actually saving
the profile.

it is also unclear from the code in comments in model.py where and how
AUTH_PROFILE_MODULE
is being handled. from our experience the object AUTH_PROFILE_MODULE
is not being writen
to at all.

Now it seems that if AUTH_PROFILE_MODULE is being defined as a
constant object then somehow
in Django there would be a way to open and save to it, during the
registration process.

We also can't find figure out how  the registration process writes the
temporary file with registration
information but does not write anything to the AUTH_PROFILE_MODULE
object as in our
myproject.mysite.models.py file and in  myproject.mysite.settings.py.



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

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 2:06 PM, Matias Surdi  wrote:

> Yes, maybe it's just a problem with sqlite, which is te backend I'm
> using.I'll try with mysql later.
>
> Is this a bug? should it be reported as a ticket?
>

I see you opened ticket #10070, which is fine because I don't know the
answer to whether it is a bug that some of the backends do not support this
style of parameter passing.  Django apparently doesn't use it internally,
nor document support for it (
http://docs.djangoproject.com/en/dev/topics/db/sql/ doesn't mention it) so
it may be permissible variation in the backends, I don't know.  Hopefully
someone who knows more than I will respond in that ticket.

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



Invalid block tag: "get_comment_count"

2009-01-19 Thread Florian Lindner

Hello,

I'm trying to use the comment framework from Django 1.0.2.

I've followed all the steps in 
http://docs.djangoproject.com/en/dev/ref/contrib/comments/ 
  (added it to installed apps, added to urls.py and loaded in the  
template: {% load comments % }) but I get:

TemplateSyntaxError at /blog/1/
Invalid block tag: 'get_comment_count'

from:

{% get_comment_count for object as comment_count %}

object has just been created so probably no comment yet attached.

What could have went wrong there?

Thanks!

Florian

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



POST sub dictionaries

2009-01-19 Thread Vinicius Mendes
Is there in django something like the PHP POST subarrays?

For example, if i do this in my form:




and submit it, i will have the following data structure in my PHP POST:

$_POST = array(
'test' => array(
0 => 0,
1 => 1
)
)

In django, i think it can turn into:

request.POST = {
'test': (0,1)
}

What means it is a dictionary with a tuple as the value of the 'test' key.

Another case is this:



Whet gives this in PHP:

$_POST = array(
'test' => array(
'key' => 1
)
)

What means the following in python:

request.POST = {
'test': {
'key': 1
}
}

Is there anything like this in django? I think it can make formsets much
more easier to use, and eliminates the needing of the management_form.



Vinícius Mendes
Engenheiro de Computação
Meio Código - A peça que faltava para o seu código!
URL http://www.meiocodigo.com

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



Re: 'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 1:54 PM, Karen Tracey  wrote:

> On Mon, Jan 19, 2009 at 12:04 PM, Thiago F. Crepaldi wrote:
>
>>
>> hello Karen,
>>
>> below is the code required. I hope you can help me =)
>>
>
> In the future, please post code of that length/width to someplace like
> dpaste.com; email makes it quite hard to read given how it gets wrapped.
>
> I think what is happening is you have added a field to your model form that
> has a name that matches a related object accessor for the model (that is,
> you have added a field with a name that matches that of a model that has a
> ForeignKey that points to your Feature model).  I've recreated the error
> with a much simpler model form based on the tutorial's Poll model:
>
> http://code.djangoproject.com/ticket/10069
>
> I thought the fix was easy but a quick run of Django's model_forms test
> shows that the quick fix I was thinking of breaks something else, and I'm
> running out of time to look at this today, so it may be a little while
> before a fix goes in.  In the meantime if you can identify the additional
> field(s) that may be causing the problem in your form, renaming them to
> something that doesn't exactly match the related model name(s) should work
> as a temporary workaround.
>

Actually the fix was simple,  I just didn't spell it properly first time
around.   Fix is now in trunk and current 1.0.X branch so if you update to
one of those levels I think the problem will go away.

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: Suspicious Operation/ filestorage problem

2009-01-19 Thread Andy Mckay

> SuspiciousOperation: Attempted access to '/img/avatars/default.gif'
> denied.

If i remember, it's because there's a / at the beginning, you probably  
want a relative path.
--
   Andy McKay
   ClearWind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 2:10 PM, NoviceSortOf  wrote:

>
> > It isn't at all clear to me from what you have posted what difficulty you
> > are having in using your own auth profile module.  I do not understand
> why
> > the presence of the django-registration table would be causing any
> trouble.
> > At any rate, since you are already using django-registration, you may
> want
> > to consider also using django-profiles, there is a link to that project
> on
> > the page I linked to above.
>
> I've loaded django-profiles and can't manage to get it to work after
> many hours
> of attempts, and after much thought of the small scale of our user/
> profile database
> and the limited scope of our website would prefer to simply the
> process by
> bringing more control of the profiles into our own coding.
>
> So my idea at this point was if the AUTH_PROFILE_MODULE
> declares a constant object that has built in functions for it, then I
> just wanted
> to build my own profile, views and model and take it from there. I'm
> not building a
> large site by any stretch of the imagination, in fact most of the
> activation,
> profile maintenance and so on we do manually, including account
> activation
> and can do direct on the data via phpAdmin, via data importation
> or some other interface.
>
> With registration working, all we need from Django is a simple hook to
> initiate
> the AUTH_PROFILE_MODULE via the related field/row of user during
> registration,
> so we can then build our own models, forms and views for our user
> profiles.
>

I'm feeling a bit dense here.  What is it, exactly, that isn't working?
What have you done, what did you expect, and what happens instead?
AUTH_PROFILE_MODULE isn't fundamentally broken, so some specifics on what
isn't working for you would help someone to help you fix whatever it is that
isn't working.  But from all you've written I still have no idea what that
is.

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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread NoviceSortOf

> It isn't at all clear to me from what you have posted what difficulty you
> are having in using your own auth profile module.  I do not understand why
> the presence of the django-registration table would be causing any trouble.
> At any rate, since you are already using django-registration, you may want
> to consider also using django-profiles, there is a link to that project on
> the page I linked to above.

I've loaded django-profiles and can't manage to get it to work after
many hours
of attempts, and after much thought of the small scale of our user/
profile database
and the limited scope of our website would prefer to simply the
process by
bringing more control of the profiles into our own coding.

So my idea at this point was if the AUTH_PROFILE_MODULE
declares a constant object that has built in functions for it, then I
just wanted
to build my own profile, views and model and take it from there. I'm
not building a
large site by any stretch of the imagination, in fact most of the
activation,
profile maintenance and so on we do manually, including account
activation
and can do direct on the data via phpAdmin, via data importation
or some other interface.

With registration working, all we need from Django is a simple hook to
initiate
the AUTH_PROFILE_MODULE via the related field/row of user during
registration,
so we can then build our own models, forms and views for our user
profiles.

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

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 12:40 PM, Ramiro Morales  > wrote:
> 
> 
> On Mon, Jan 19, 2009 at 3:15 PM, Matias Surdi  > wrote:
>  >
>  > The curious thing here, is that the above query works perfect
> running it
>  > directly through sqlite3.
>  >
> 
>  From what I have seen by reading DB backend source code, Django
> cursor's
> execute() method supports only the printf-like parmeter maker style
> with a list
> or tuple of actual parameters.
> 
> If you want to use the pyformat parameter marking style (as described
> in PEP 249),
> you' ll need to use the native DB-API driver API as you've already
> discovered.
> 
> 
> I didn't look at any code, I just tried a similar query on my own DB, 
> using current 1.0.X branch code:
> 
> k...@lbox:~/software/web/xword$ python manage.py shell
> Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>  >>> from django.db import connection
>  >>> query = "SELECT * FROM Authors WHERE Author = %(name)s"
>  >>> parms = {'name': 'Manny Nosowsky'}
>  >>> cursor = connection.cursor()
>  >>> data = cursor.execute(query, parms)
>  >>> data
> 1L
>  >>> cursor.fetchall()
> ((4L, u'Manny Nosowsky', u'No', u''),)
>  >>>
>  >>>
> 
> That's using MySQL as the DB, so perhaps it is backend-specific?  The 
> only thing I needed to do to make the example shown originally work is 
> remove the quotes (and use table/column/parm names that exist in my DB).
> 
> Karen
> 
> > 


Yes, maybe it's just a problem with sqlite, which is te backend I'm 
using.I'll try with mysql later.

Is this a bug? should it be reported as a ticket?




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 12:04 PM, Thiago F. Crepaldi wrote:

>
> hello Karen,
>
> below is the code required. I hope you can help me =)
>

In the future, please post code of that length/width to someplace like
dpaste.com; email makes it quite hard to read given how it gets wrapped.

I think what is happening is you have added a field to your model form that
has a name that matches a related object accessor for the model (that is,
you have added a field with a name that matches that of a model that has a
ForeignKey that points to your Feature model).  I've recreated the error
with a much simpler model form based on the tutorial's Poll model:

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

I thought the fix was easy but a quick run of Django's model_forms test
shows that the quick fix I was thinking of breaks something else, and I'm
running out of time to look at this today, so it may be a little while
before a fix goes in.  In the meantime if you can identify the additional
field(s) that may be causing the problem in your form, renaming them to
something that doesn't exactly match the related model name(s) should work
as a temporary workaround.

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



views, templates, render and groups

2009-01-19 Thread garagefan

pretty vague title i know...

Can I return a query set via  foo.object.filter() where in filter i
check a manytomany field in foo against the group field for a user?

I guess a way to use a group as a permission?

IE: An article that would normally appear with a ton of other
articles, in a ManyToMany field tied to groups has been set to Group1.
Now a handful of users are in Group1 and that article is only supposed
to be visible to those people, as well as the other non-group assigned
articles in the list.

I'd like to take care of this in the views in the render for the
template so that only the objects that can be viewed are passed
through. It seems that permissions are set up by django based on the
models themselves, and i haven't seen anything on creating custom
permissions for groups themselves. So any of the permission check
functions would not work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



post login redirects with ssl rverse proxy

2009-01-19 Thread chris

Hi Guys
I've got an an internal site on a http://internal1 that we want to
expose to the world using a apache reverse proxy running SSL i.e
https://external.org
We're using mod_proxy mod_proxy_html

ProxyPass /external/ http://internal

ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap /   /internal1/
ProxyHTMLURLMap /internal1   /internal1
ProxyHTMLURLMap /internal1  /internal1/media/
ProxyHTMLURLMap /site_media   /internal1/site_media
ProxyHTMLURLMap /admin   /internal1/admin/
DefaultType None
RequestHeader   unset   Accept-Encoding

Note we are also a spyce and php application (http://internal2,http://
interna3) that we also want to expose and we only have one fixed ip
and SSL cert assigned to external.org. As such we can't use as
separate virtual server for each external application

Every thing basically works  (IE of course has been a bitch!!)
except that when you login in you get redirected to the http://external
My login (@login_required) my login template looks like



Username:{{ form.username }}


Password:{{ form.password }}



note this works fine with http://internal1
Can anyone give me some pointers??
Thanks
Regards
Chris



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



Re: Raw SQL parameters

2009-01-19 Thread Ramiro Morales

On Mon, Jan 19, 2009 at 3:56 PM, Karen Tracey  wrote:

>
> That's using MySQL as the DB, so perhaps it is backend-specific?

So it seems. the MySQL and PostgreSQL backend seem to (still?)
support it. But the Oracle crew removed it a while back:

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

Regards,

-- 
 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: Raw SQL parameters

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 12:40 PM, Ramiro Morales  wrote:

>
> On Mon, Jan 19, 2009 at 3:15 PM, Matias Surdi 
> wrote:
> >
> > The curious thing here, is that the above query works perfect running it
> > directly through sqlite3.
> >
>
> From what I have seen by reading DB backend source code, Django cursor's
> execute() method supports only the printf-like parmeter maker style with a
> list
> or tuple of actual parameters.
>
> If you want to use the pyformat parameter marking style (as described
> in PEP 249),
> you' ll need to use the native DB-API driver API as you've already
> discovered.
>
>
I didn't look at any code, I just tried a similar query on my own DB, using
current 1.0.X branch code:

k...@lbox:~/software/web/xword$ python manage.py shell
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.db import connection
>>> query = "SELECT * FROM Authors WHERE Author = %(name)s"
>>> parms = {'name': 'Manny Nosowsky'}
>>> cursor = connection.cursor()
>>> data = cursor.execute(query, parms)
>>> data
1L
>>> cursor.fetchall()
((4L, u'Manny Nosowsky', u'No', u''),)
>>>
>>>

That's using MySQL as the DB, so perhaps it is backend-specific?  The only
thing I needed to do to make the example shown originally work is remove the
quotes (and use table/column/parm names that exist in my DB).

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



Compare the fields of the same model

2009-01-19 Thread Costin Stroie

Hi!

I have the following model:

class MyModel(models.Model):
maxwidth = models.IntegerField(Maximum width', default = '0')
width = models.IntegerField('Width', default = '0')

I need to perform a query similar to this:

SELECT * FROM mymodel WHERE width > maxwidth;

The result should be a queryset, since I need it as filter in a long
chain of filters. Moreover, I need it to be able to be OR'ed to some
other querysets, so I found a simple .extra(where = ['width >
maxwidth']) won't work (the WHERE clause is placed in a wrong
position).

How can I do it? Maybe a forged Q object? Well, I'm stuck.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Raw SQL parameters

2009-01-19 Thread Ramiro Morales

On Mon, Jan 19, 2009 at 3:15 PM, Matias Surdi  wrote:
>
> The curious thing here, is that the above query works perfect running it
> directly through sqlite3.
>

>From what I have seen by reading DB backend source code, Django cursor's
execute() method supports only the printf-like parmeter maker style with a list
or tuple of actual parameters.

If you want to use the pyformat parameter marking style (as described
in PEP 249),
you' ll need to use the native DB-API driver API as you've already discovered.

Regards,

-- 
 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: Raw SQL parameters

2009-01-19 Thread Matias Surdi

Karen Tracey escribió:
> On Mon, Jan 19, 2009 at 11:49 AM, Matias Surdi  > wrote:
> 
> 
> Hi,
> 
> 
> I'm trying to run a sql query with parameters taken from a dict, here is
> the relevant part of the code:
>query = "select * from table where name='%(name)s'"
> 
> 
> Remove the single quotes around '%(name)s'.  The backend will handle 
> quoting, I expect the extra quotes are causing confusion somewhere.
> 
> Karen
>  
> 
> 
>parameters = {'name':'valueofname'}
> cursor = connection.cursor()
> data = cursor.execute(query,parameters)
> 
> 
> The error I get is:
> 
> TypeError: format requires a mapping
> 
> 
> But, as far as I know (from PEP249) this should be possible.
> Basically, what I need, is to pass the parameters values in a dict, and
> not as a list or tuple as is shown in django docs.
> 
> Which is the correct way to accomplish this?
> 
> Thanks a lot.
> 
> 
> > 



Sorry, these quotes are a typo, the running code doesn't have them.

I've also tried with:

cursor.execute("select * from table where 
field=:value",{'value':'something'})

And I got the error:
"Type error: not all arguments converted during string formatting"


The curious thing here, is that the above query works perfect running it 
directly through sqlite3.



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

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 11:49 AM, Matias Surdi wrote:

>
> Hi,
>
>
> I'm trying to run a sql query with parameters taken from a dict, here is
> the relevant part of the code:
>query = "select * from table where name='%(name)s'"


Remove the single quotes around '%(name)s'.  The backend will handle
quoting, I expect the extra quotes are causing confusion somewhere.

Karen


>
>parameters = {'name':'valueofname'}
> cursor = connection.cursor()
> data = cursor.execute(query,parameters)
>
>
> The error I get is:
>
> TypeError: format requires a mapping
>
>
> But, as far as I know (from PEP249) this should be possible.
> Basically, what I need, is to pass the parameters values in a dict, and
> not as a list or tuple as is shown in django docs.
>
> Which is the correct way to accomplish this?
>
> Thanks a lot.
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Thiago F. Crepaldi

hello Karen,

below is the code required. I hope you can help me =)


thanks in advance
Thiago

here is the FEATURE MODEL unique property
#
# Fields that should be unique together in the database.
#
unique_together = [("featureId", "pf", "intComponent", "db",
"pd")]


here is the def searchFeature in the views.py
#*
#  searchFeature
#*
def searchFeature(request, view = None):
if request.method == 'POST':
form = SearchFeatureForm(request.POST)
if form.is_valid():
# Perform the query

ftrQuery = Feature.objects.all().order_by('featureId',
'pk')

# Remove empty fields and start filtering
if request.POST.__getitem__('featureId') != "":
ftrQuery = ftrQuery.filter(featureId__contains =
request.POST.__getitem__('featureId')).distinct()

if request.POST.__getitem__('name') != "":
ftrQuery = ftrQuery.filter(name__icontains =
request.POST.__getitem__('name')).distinct()

if request.POST.__getitem__('pf') != "":
ftrQuery = ftrQuery.filter(platform =
request.POST.__getitem__('pf')).distinct()

if request.POST.__getitem__('state') != "":
ftrQuery = ftrQuery.filter(state =
request.POST.__getitem__('state')).distinct()

if request.POST.__getitem__('db') != "":
ftrQuery = ftrQuery.filter(drumbeat__pk =
request.POST.__getitem__('db')).distinct()

if request.POST.__getitem__('intComponent') != "":
ftrQuery = ftrQuery.filter(intComponent =
request.POST.__getitem__('intComponent')).distinct()

if request.POST.__getitem__('estimator') != "":
ftrQuery = ftrQuery.filter
(estimate__estimator__name__icontains = request.POST.__getitem__
('estimator')).distinct()

if request.POST.__getitem__('ftrStartYear') != "":
ftrStartYear = int(request.POST.__getitem__
('ftrStartYear'))

if request.POST.__getitem__('ftrStartMonth') != "":
ftrStartMonth = int(request.POST.__getitem__
('ftrStartMonth'))

if request.POST.__getitem__('owner') != "":
ftrQuery = ftrQuery.filter(owner__pk =
request.POST.__getitem__('owner'))

if request.POST.__getitem__('pd') != "":
ftrQuery = ftrQuery.filter(product__contains =
request.POST.__getitem__('pd'))

from datetime import date
if request.POST.__getitem__('ftrStartYear') != "" and
request.POST.__getitem__('ftrStartMonth') != "":
ftrQuery = ftrQuery.filter(date__gte = date
(ftrStartYear, ftrStartMonth, 1)).distinct()

if request.POST.__getitem__('teamMember') != "":
role = request.POST.__getitem__('memberRole')
if role == "ANY":
role = ""
ftrQuery = ftrQuery.filter(Q
(teammember__employee__name__icontains = request.POST.__getitem__
('teamMember')) & Q(teammember__role__contains = role)).distinct()

actualEffortLow  = 0
actualEffortHigh = 0
if request.POST.__getitem__('actualEffortLow') != '':
actualEffortLow = int(request.POST.__getitem__
('actualEffortLow'))

if request.POST.__getitem__('actualEffortHigh') != '':
actualEffortHigh = int(request.POST.__getitem__
('actualEffortHigh'))

if request.POST.__getitem__('actualEffortLow') != '' or
request.POST.__getitem__('actualEffortHigh') != '':
ftrQuery = ftrQuery.filter(Q(actual__type__contains=
'effort') & Q(actual__actual__gte = actualEffortLow) & Q
(actual__actual__lte = actualEffortHigh)).distinct()

actualSizeLow  = 0
actualSizeHigh = 0
if request.POST.__getitem__('actualSizeLow') != '':
actualSizeLow = int(request.POST.__getitem__
('actualSizeLow'))

if request.POST.__getitem__('actualSizeHigh') != '':
actualSizeHigh = int(request.POST.__getitem__
('actualSizeHigh'))

if request.POST.__getitem__('actualSizeLow') != '' or
request.POST.__getitem__('actualSizeHigh') != '':
ftrQuery = ftrQuery.filter(Q
(actual__type__contains='size') & Q(actual__actual__gte =
request.POST.__getitem__('actualSizeLow')) & Q(actual__actual__lte =
request.POST.__getitem__('actualSizeHigh'))).distinct()

queryTeamSizeLow = request.POST.__getitem__('teamSizeLow')
queryTeamSizeHigh = request.POST.__getitem__
('teamSizeHigh')

#Only way I could find to select with COUNT without
writting the SQL code.
if que

Re: django_extensions and AutoSlugField

2009-01-19 Thread Dan Jewett



On Jan 19, 11:03 am, Dan Jewett  wrote:
> Maybe I'm just implementing this incorrectly, but if anyone is using
> this extension maybe you could shed some light on this error.
>
> When I try to add or save my Model I get:
> AttributeError: 'str' object has no attribute 'creation_counter'
>
> Here's what I think is relevant.
> in models.py: (partial)
> from django_extensions.db.fields import AutoSlugField
>
> class Album(models.Model):
>     title = models.CharField(max_length=250)
>     slug = AutoSlugField(populate_from=title, max_length=250,
> editable=True)
>     # slug = models.SlugField(max_length=250)
>
> in admin.py: (partial)
>
> class AlbumOptions(admin.ModelAdmin):
>     prepopulated_fields = {'slug': ('title',)}
>
> On Album Add or Save, I get the error.
>
> 
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> site-packages/django_extensions/db/fields/__init__.py" in pre_save
>   108.         value = unicode(self.create_slug(model_instance, add))
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> site-packages/django_extensions/db/fields/__init__.py" in create_slug
>   63.         populate_field = model_instance._meta.get_field
> (self._populate_from)
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> site-packages/django/db/models/options.py" in get_field
>   260.             if f.name == name:
> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> site-packages/django/db/models/fields/__init__.py" in __cmp__
>   102.         return cmp(self.creation_counter,
> other.creation_counter)
>
> Exception Type: AttributeError at /admin/fc/album/1/
> Exception Value: 'str' object has no attribute 'creation_counter'
>
> Local vars:
> other 'id'
> self 
>
> Thanks for any suggestions.
> Dan J.

Found it. populate_from wants a string.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Blueprint css versus YUI grids versus ?

2009-01-19 Thread Rock

I have generated several static sites using Django aym-cms,
blueprint.css and markdown. This worked so well that I created a
django app that encapsulates blueprint.css so that I now have the
ability to manipulate layouts dynamically. Next up is to hook up
"pagelets" (i.e., django-chunks, django-modular, etc.) to create
sublayout units that I call "gridlets" to boost this stuff into the
realm of end user directed (or at least selected) layouts.

On Jan 19, 8:52 am, felix  wrote:
> I've also enjoyed blueprint for its clarity and speed.
>
> ideally I would love to assign more semantic .classes and #ids and then use
> a style sheet that assigns to styles to styles (yo dawg ... )
>
> .detail {
>  {% blueprint 'span-8' %}
>  {% blueprint 'box' %}
>   border: 1px solid {{ui.bordercolor}};
>
> }
>
> and then something like django-compress would render this final css by
> parsing the blueprint CSS, copying the style defs over and into the actual
> style sheet.
>
> note also inserting vars from a ui object
>
> this would be something like django-compress could do.
>
> On Mon, Jan 19, 2009 at 3:02 PM, bruno desthuilliers <
>
> bruno.desthuilli...@gmail.com> wrote:
>
> > On 17 jan, 22:03, ydjango  wrote:
> > > has anyone used Blue Print css?
>
> > Yes. Tried it for a personal project, found it nice at first - and to
> > be true, it really helped me prototyping. But now the design is ok to
> > me, I'm in the process of rewriting all my markup and css to get rid
> > of the "grid.css" part. There was too much markup that was just here
> > to make blueprint work, and I don't like the kind of "reinventing
> > table layout with css" feeling it had.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 10:17 AM, NoviceSortOf  wrote:

>
>
> OK. Please correct me if I'm wrong
>
> The  "registration_registrationprofile"  is simply a reference table
> created during
> the process of creating an inactive account.
>


This table is not coming from base Django.  Based on the name (tables are
generally named appname_modelname), you appear to be using
django-registration:

http://bitbucket.org/ubernostrum/django-registration/wiki/Home

Looking at the source for that, yes, it looks like this table is used simply
to store activation keys during the registration process.


>
> * If that is the case then how do I simply create a related record to
> users in
>  "myproject.myprofiles"  as set in settings.py as
> AUTH_PROFILE_MODULE ?
>
> * I want to create my own profiles routine based on the data I've
> already defined in
>   "myproject.myprofiles"  what is the simplest way to do that?
>

It isn't at all clear to me from what you have posted what difficulty you
are having in using your own auth profile module.  I do not understand why
the presence of the django-registration table would be causing any trouble.
At any rate, since you are already using django-registration, you may want
to consider also using django-profiles, there is a link to that project on
the page I linked to above.

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



Raw SQL parameters

2009-01-19 Thread Matias Surdi

Hi,


I'm trying to run a sql query with parameters taken from a dict, here is 
the relevant part of the code:
query = "select * from table where name='%(name)s'"
parameters = {'name':'valueofname'}
 cursor = connection.cursor()
 data = cursor.execute(query,parameters)


The error I get is:

TypeError: format requires a mapping


But, as far as I know (from PEP249) this should be possible.
Basically, what I need, is to pass the parameters values in a dict, and 
not as a list or tuple as is shown in django docs.

Which is the correct way to accomplish this?

Thanks a lot.


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



Suspicious Operation/ filestorage problem

2009-01-19 Thread bax...@gretschpages.com

My SiteUser model allows an avatar upload. If there's not one, it
assigns a default image on save:

def save(self, *args, **kwargs):
 ...
if self.avatar is None:
 self.avatar = "img/avatars/default.gif"

super(SiteUser, self).save(*args, **kwargs)

Pretty straightforward. Problem, is, later when I try to get height of
avatar (siteuser.avatar.height) It fails whenever the avatar is
default. gif with a suspicious operation error:

...
 File "/home/grmadmin/webapps/django/lib/python2.5/django/core/files/
storage.py", line 204, in path
   raise SuspiciousOperation("Attempted access to '%s' denied." %
name)

SuspiciousOperation: Attempted access to '/img/avatars/default.gif'
denied.

I've checked permissions on default.gif, but that doesn't appear to be
it.
I can call siteuser.avatar with no problem, but siteuser.avatar.height
fails every time, if the avatar is default.gif



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: proper way to use S3Storage and Django ImageField

2009-01-19 Thread Aaron Lee
So I guess S3Storage doesn't work with ImageField? Can anyone confirm that?

-Aaron

On Thu, Jan 15, 2009 at 10:30 AM, Aaron  wrote:

>
> ping?
>
> On Jan 12, 9:53 am, "Aaron Lee"  wrote:
> > Hi all and David,
> >
> > I followed thehttp://code.larlet.fr/doc/django-s3-storage.html
> > installation and created a simple model
> >
> > class Avatar(models.Model):
> > """
> > Avatar model
> > """
> > image = models.ImageField(upload_to="userprofile")
> > user = models.ForeignKey(User)
> >
> > By using the upload_to="userprofile" (which is also the example given on
> the
> > django-s3-storage.html)
> > the path would be something like userprofile/my.jpg
> > which would trigger the file storage backend exception
> >
> > File "/usr/local/src/djtrunk.latest/django/core/files/storage.py", line
> 81,
> > in path
> > raise NotImplementedError("This backend doesn't support absolute paths.")
> > where name is userprofile/my.jpg
> >
> > What's the recommended way of using S3 with ImageField?
> >
> > -Aaron
> >
>

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



django_extensions and AutoSlugField

2009-01-19 Thread Dan Jewett

Maybe I'm just implementing this incorrectly, but if anyone is using
this extension maybe you could shed some light on this error.

When I try to add or save my Model I get:
AttributeError: 'str' object has no attribute 'creation_counter'

Here's what I think is relevant.
in models.py: (partial)
from django_extensions.db.fields import AutoSlugField

class Album(models.Model):
title = models.CharField(max_length=250)
slug = AutoSlugField(populate_from=title, max_length=250,
editable=True)
# slug = models.SlugField(max_length=250)

in admin.py: (partial)

class AlbumOptions(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}

On Album Add or Save, I get the error.


File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django_extensions/db/fields/__init__.py" in pre_save
  108. value = unicode(self.create_slug(model_instance, add))
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django_extensions/db/fields/__init__.py" in create_slug
  63. populate_field = model_instance._meta.get_field
(self._populate_from)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django/db/models/options.py" in get_field
  260. if f.name == name:
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
site-packages/django/db/models/fields/__init__.py" in __cmp__
  102. return cmp(self.creation_counter,
other.creation_counter)

Exception Type: AttributeError at /admin/fc/album/1/
Exception Value: 'str' object has no attribute 'creation_counter'

Local vars:
other 'id'
self 

Thanks for any suggestions.
Dan J.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



FileBrowser and TinyMCE

2009-01-19 Thread martyn

Hi,

I'm trying to get TinyMCE working with django-filebrowser.

I started to make Tiny working :

# === settings.py :
INSTALLED_APPS = (
#...
'tinymce',
'filebrowser',
#...
)
TINYMCE_JS_URL = MEDIA_URL + 'js/tiny_mce/tiny_mce_src.js'
URL_TINYMCE = TINYMCE_JS_URL
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,paste,advimage,advlink",
'extended_valid_elements' : "a[name|href|target|title|onclick|
rel]",
'theme':'advanced',
'theme_advanced_toolbar_location' : "top",
'file_browser_callback' : "CustomFileBrowser",
'theme_advanced_buttons1' :
"code,separator,forecolor,backcolor,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,advimage,image,hr",
'theme_advanced_buttons2' :
"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator",
'theme_advanced_buttons3' :
"table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,row_after,row_before,split_cells,merge_cells",
}
TINYMCE_FILEBROWSER = True


# === forms.py
# -*- coding: utf-8 -*-
from django import forms
from app.models import Article
from tinymce.widgets import TinyMCE

class BaseArticleForm(forms.ModelForm):
introtext = forms.CharField(widget=TinyMCE(attrs={'cols': 80,
'rows': 20}))
class Meta:
model = Article


# === template
{{ form.media }}
{{ form.as_table }}


# === template for integration (/tinymce/filebrowser.js )
function CustomFileBrowser(field_name, url, type, win) {

var cmsURL = "/admin/filebrowser/?pop=2";
cmsURL = cmsURL + "&type=" + type;

tinyMCE.activeEditor.windowManager.open({
file: cmsURL,
width: 820,  // Your dimensions may differ - toy around with
them!
height: 500,
resizable: "yes",
scrollbars: "yes",
inline: "no",  // This parameter only has an effect if you use
the inlinepopups plugin!
close_previous: "no",
}, {
window: win,
input: field_name,
editor_id: tinyMCE.selectedInstance.editorId,
});
return false;
}

tinyMCE.init({
file_browser_callback : "CustomFileBrowser"
});



When I click on the icon which open the filebrowser, I have nothing
except that error :
Erreur : f has no properties
Fichier source : http://127.0.0.1:8000/medias/js/tiny_mce/tiny_mce_src.js
Ligne : 7516

I don't understand, in the doc it seems so easy, I spent my entire
morning on that.
Thanks a lot for helping me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing raw form data

2009-01-19 Thread Dennis Schmidt

OK, I just found it myself. The dictionary I was looking for is just
called data.

On 19 Jan., 16:45, Dennis Schmidt  wrote:
> Hello,
>
> After calling the clean() method of a form the whole cleaned_data
> ditionary is returned. But when the clean() method raises an error,
> the dictionary is emptied it seems since raising an error can't as
> well return any values of course.
>
> My problem now is, that I do need to access these values after
> validation, no matter if it's valid or not. So I was searching for
> anything like a raw_data dictionary but couldn't find any.
>
> So is there ANY possibility to access the form data after validation
> even if some fields are invalid?
>
> Thanks in advance,
> Dennis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



accessing raw form data

2009-01-19 Thread Dennis Schmidt

Hello,

After calling the clean() method of a form the whole cleaned_data
ditionary is returned. But when the clean() method raises an error,
the dictionary is emptied it seems since raising an error can't as
well return any values of course.

My problem now is, that I do need to access these values after
validation, no matter if it's valid or not. So I was searching for
anything like a raw_data dictionary but couldn't find any.

So is there ANY possibility to access the form data after validation
even if some fields are invalid?

Thanks in advance,
Dennis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread NoviceSortOf


OK. Please correct me if I'm wrong

The  "registration_registrationprofile"  is simply a reference table
created during
the process of creating an inactive account.

* If that is the case then how do I simply create a related record to
users in
 "myproject.myprofiles"  as set in settings.py as
AUTH_PROFILE_MODULE ?

* I want to create my own profiles routine based on the data I've
already defined in
   "myproject.myprofiles"  what is the simplest way to do that?

Please advise
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread NoviceSortOf


I'm rewording my question for clarification.

* Where is  the model file for "registration_registrationprofile" ?

  _If I go to ...site-packages/registration where I would assume the
models.py file would contain the definition for this table,
it does not exist there.

* Why does the "registration_registrationprofile" table populate when
"myproject.myprofiles" is set in settings.py as AUTH_PROFILE_MODULE ?


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



AUTH_PROFILE_MODULE setting does not relate at all to actual reg file being populated

2009-01-19 Thread NoviceSortOf


In my settings file I've set AUTH_PROFILE_MODULE =
"myproject.myprofiles"

Looking at my database, I've something called
"registration_registrationprofile"

I've defined myproject.myprofiles in models.py and the file clearly
exists.

Instead though "registration_registrationprofile" is the file that
continues to be acted on.

Since "registration_registrationprofile" is populating beautifully
over hundreds of records,
I'd like to use that file and expand it with more fields for
customized profile use.

So my problem is twofold.

* Where is  the model file for "registration_registrationprofile" ?
  _If I go to ...site-packages/registration where I would assume the
models.py
   file would contain the definition for this data it does not exist
there.

* While does  "registration_registrationprofile" populate when
"myproject.myprofiles" is
  set in settings.py as AUTH_PROFILE_MODULE ?





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Blueprint css versus YUI grids versus ?

2009-01-19 Thread felix
I've also enjoyed blueprint for its clarity and speed.

ideally I would love to assign more semantic .classes and #ids and then use
a style sheet that assigns to styles to styles (yo dawg ... )

.detail {
 {% blueprint 'span-8' %}
 {% blueprint 'box' %}
  border: 1px solid {{ui.bordercolor}};
}

and then something like django-compress would render this final css by
parsing the blueprint CSS, copying the style defs over and into the actual
style sheet.

note also inserting vars from a ui object

this would be something like django-compress could do.


On Mon, Jan 19, 2009 at 3:02 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
>
> On 17 jan, 22:03, ydjango  wrote:
> > has anyone used Blue Print css?
>
> Yes. Tried it for a personal project, found it nice at first - and to
> be true, it really helped me prototyping. But now the design is ok to
> me, I'm in the process of rewriting all my markup and css to get rid
> of the "grid.css" part. There was too much markup that was just here
> to make blueprint work, and I don't like the kind of "reinventing
> table layout with css" feeling it had.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Karen Tracey
On Mon, Jan 19, 2009 at 7:50 AM, Thiago F. Crepaldi wrote:

>
> Hello,
>
> I am migrating a system from django 0.97 (svn) to 1.0.2 (stable) and I
> got the following error when a [database] SEARCH FORM is submitted :
> 'RelatedObject' object has no attribute 'unique'
>
> I recreated all tables through 'python manage.db syncdb' command and
> imported all the old data back again.
>

Just FYI, this is not necessary to migrate from .9x to 1.0.2.  Tables from
.9x installations work perfectly well with 1.0.x.


>
> It looks like that all unique indexes declared were created correctly
> on the MySQL database.
>
> In fact, I didn't even understand what this error means. Can someone
> help me out ?
>

It would be easier to help if you shared the code you have in your
ftrTool\views.py searchFeature function, as well as the form definition you
are using.  All I can say from the traceback below is that the unique
validation code is finding it's got a RelatedObject object where it is
expecting to have something else.  Whether that is a bug in your code or in
the unique validation code is hard to say without seeing your code.

Karen


>
> I already read
>http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/
> and
>http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> and, unfortunately, had no luck =/
>
>
> Environment:
>
> Request Method: POST
> Request URL: http://localhost:8000/ftrTool/searchFeature/
> Django Version: 1.0.2 final
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.admin',
> 'webTool.ftrTool']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.middleware.doc.XViewMiddleware')
>
>
> Traceback:
> File "C:\PYTHON25\Lib\site-packages\django\core\handlers\base.py" in
> get_response
>  86. response = callback(request, *callback_args,
> **callback_kwargs)
> File "D:\thiago\dados\eclipse_workspace\webTool\..\webTool\ftrTool
> \views.py" in searchFeature
>  474. if form.is_valid():
> File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in is_valid
>  120. return self.is_bound and not bool(self.errors)
> File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in
> _get_errors
>  111. self.full_clean()
> File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in
> full_clean
>  241. self.cleaned_data = self.clean()
> File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in clean
>  223. self.validate_unique()
> File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in
> validate_unique
>  251. if f.unique and self.cleaned_data.get(name) is not
> None:
>
> Exception Type: AttributeError at /ftrTool/searchFeature/
> Exception Value: 'RelatedObject' object has no attribute 'unique'
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Blueprint css versus YUI grids versus ?

2009-01-19 Thread bruno desthuilliers



On 17 jan, 22:03, ydjango  wrote:
> has anyone used Blue Print css?

Yes. Tried it for a personal project, found it nice at first - and to
be true, it really helped me prototyping. But now the design is ok to
me, I'm in the process of rewriting all my markup and css to get rid
of the "grid.css" part. There was too much markup that was just here
to make blueprint work, and I don't like the kind of "reinventing
table layout with css" feeling it had.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: what to use for search facility

2009-01-19 Thread Tom Dyson

For non-Russian speakers, see

http://code.google.com/p/django-sphinx/

I've used the Postgres + tsearch approach, with something like this
for Django integration:

http://smelaatifi.blogspot.com/2007/09/full-text-search-with-tsearch2-and.html

On Jan 19, 8:49 am, Konstantin  wrote:
> On Jan 19, 10:29 am, krylatij  wrote:
>
> > Sphinx
> > Here 
> > sampleshttp://softwaremaniacs.org/blog/2007/11/04/sphinx-search-in-cicero/
> > (but in Russian)
>
> Thank you very much! I'll have a look
>
> (Being native Russian I'll have no problem reading this text :) )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Comparing BoundField values in templates

2009-01-19 Thread ekellner

Hi, I am having trouble working with a BoundField value in a template.

What I have is a IntergerField that is represented by a set of Radio
Buttons in html. I want to lay out these buttons myself, and plus
there's javascript involved.  I don't believe there's a way to do this
while letting the field render itself.

I need to have the "checked" attribute set for the appropriate radio
button, according to the bound field value on the form.I am trying
to do this manually -- to print out "checked" inside the input element
a manual comparison of the bound field's value, but it isn't working.
 Note that I need to do this even when the form doesn't validate, so I
need to pull the value from form.field.initial or form.field.data
selectively, and so I have a template filter tag to do this.

Here's the code, isolated:

### a filter to get the bound field value independent of whether it
comes from initial/data
@register.filter
def boundvalue(boundfield):
"Copied from BoundField.as_widget"
if not boundfield.form.is_bound:
data = boundfield.form.initial.get(boundfield.name,
boundfield.field.initial)
if callable(data):
data = data()
else:
data = boundfield.data
return data

### My Template


### The HTML page:


As you can see, I am getting some kind of string-typed output on the
page, so I've got *some* value. It casts to boolean true, but I
haven't been able to successfully compare it to 0.

If there's a better way to do this overall, I would also welcome
suggestions.  I am not especially attached to solving this using
string comparisons but the form.data hash seems to force me down this
road.

Thank you
Elizabeth

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



the inline form is not effect

2009-01-19 Thread friskyrain

I want to deal the m2m relationship in django admin site.I customized
the inline class,modified the form and formset .But nothing is
changed,and no mistake happen.
I see the django website release notes,which said has fixed inline
form bug.I do know  how to do .
this is my model.py
#coding=utf-8
# Create your models here.

from django.db import models
from django.contrib import admin
from django import forms
from django.forms.models import inlineformset_factory
from django.forms import ModelForm

class totattrib(models.Model):
name=models.CharField(max_length=30,unique=True)
description=models.CharField(max_length=60,blank=True)

def __unicode__(self):
return self.name

class subattrib(models.Model):
name=models.ForeignKey(totattrib)
subname=models.CharField(max_length=30,unique=True)
description=models.CharField(max_length=60,blank=True)

def __unicode__(self):
return self.subname


class resources(models.Model):
name = models.CharField(max_length=60,unique=True)
urls = models.URLField()
startingdate = models.DateField(auto_now_add=True)
endingdate = models.DateField(blank=True,null=True)
published_choices = (
('y', 'yes'),
('n', 'no'),
)
published = models.CharField(max_length=2,
choices=published_choices)
usages = models.URLField(blank=True)
attribs = models.ManyToManyField(subattrib,
through='resourcehash')

def show_sub(value):
objects = value.attribs.all().order_by("id")
str=''
for obj in objects:
str += ''+obj.subname+''
str+=''
return str
show_sub.allow_tags=True

def __unicode__(self):
return self.name

class resourcehash(models.Model):
resource=models.ForeignKey(resources)
attrib=models.ForeignKey(subattrib)

def __unicode__(self):
return self.resource.name + " " + self.attrib.subname

class resourcesadminform(forms.ModelForm):
class Meta:
model = subattrib
fields=('subname',)
class resourceadminform(forms.ModelForm):
class Meta:
model = resourcehash
fields = ('id','resource', 'attrib')

resourceFormSet = inlineformset_factory(resources, resourcehash,
fk_name="resource",form=resourceadminform, can_delete=False)



this is admin.py

#coding=utf-8
#!/usr/bin/env python
from django.contrib import admin
from django import forms
from lib.esource.models import
resources,totattrib,subattrib,resourcehash,resourcesadminform,resourceadminform,resourceFormSet

class resourcehashInline(admin.TabularInline):
model=resourcehash
formset=resourceFormSet
form=resourcesadminform
#template="admin/esource/resources/inline.html"
extra=1

class resourcesAdmin(admin.ModelAdmin):
inlines = (resourcehashInline,)
list_display=
('name','urls','startingdate','endingdate','published','show_sub')
list_filter=('attribs','published')
search_fields=('name',)
admin.site.register(resources, resourcesAdmin)

class subattribAdmin(admin.ModelAdmin):
list_select_related=True
list_display=('name','subname','description')
list_display_links=('subname',)
list_filter=('name',)
#inlines = (resourcehashInline,)
admin.site.register(subattrib, subattribAdmin)

class totattribAdmin(admin.ModelAdmin):
list_display=('name','description')
admin.site.register(totattrib,totattribAdmin)


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



'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Thiago F. Crepaldi
Hello,

I am migrating a system from django 0.97 (svn) to 1.0.2 (stable) and I got
the following error when a [database] SEARCH FORM is submitted :
'RelatedObject' object has no attribute 'unique'

I recreated all tables through 'python manage.db syncdb' command and
imported all the old data back again.

It looks like that all unique indexes declared were created correctly on the
MySQL database.

In fact, I didn't even understand what this error means. Can someone help me
out ?

I already read
http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/ and
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
and, unfortunately, had no luck =/


Environment:

Request Method: POST
Request URL: http://localhost:8000/ftrTool/searchFeature/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'webTool.ftrTool']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')


Traceback:
File "C:\PYTHON25\Lib\site-packages\django\core\handlers\base.py" in
get_response
 86. response = callback(request, *callback_args,
**callback_kwargs)
File "D:\thiago\dados\eclipse_workspace\webTool\..\webTool\ftrTool\views.py"
in searchFeature
 474. if form.is_valid():
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in is_valid
 120. return self.is_bound and not bool(self.errors)
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in _get_errors
 111. self.full_clean()
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in full_clean
 241. self.cleaned_data = self.clean()
File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in clean
 223. self.validate_unique()
File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in
validate_unique
 251. if f.unique and self.cleaned_data.get(name) is not None:

Exception Type: AttributeError at /ftrTool/searchFeature/
Exception Value: 'RelatedObject' object has no attribute 'unique'


--
Thiago

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



'RelatedObject' object has no attribute 'unique'

2009-01-19 Thread Thiago F. Crepaldi

Hello,

I am migrating a system from django 0.97 (svn) to 1.0.2 (stable) and I
got the following error when a [database] SEARCH FORM is submitted :
'RelatedObject' object has no attribute 'unique'

I recreated all tables through 'python manage.db syncdb' command and
imported all the old data back again.

It looks like that all unique indexes declared were created correctly
on the MySQL database.

In fact, I didn't even understand what this error means. Can someone
help me out ?

I already read
http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/
and
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
and, unfortunately, had no luck =/


Environment:

Request Method: POST
Request URL: http://localhost:8000/ftrTool/searchFeature/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'webTool.ftrTool']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')


Traceback:
File "C:\PYTHON25\Lib\site-packages\django\core\handlers\base.py" in
get_response
 86. response = callback(request, *callback_args,
**callback_kwargs)
File "D:\thiago\dados\eclipse_workspace\webTool\..\webTool\ftrTool
\views.py" in searchFeature
 474. if form.is_valid():
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in is_valid
 120. return self.is_bound and not bool(self.errors)
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in
_get_errors
 111. self.full_clean()
File "C:\PYTHON25\Lib\site-packages\django\forms\forms.py" in
full_clean
 241. self.cleaned_data = self.clean()
File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in clean
 223. self.validate_unique()
File "C:\PYTHON25\Lib\site-packages\django\forms\models.py" in
validate_unique
 251. if f.unique and self.cleaned_data.get(name) is not
None:

Exception Type: AttributeError at /ftrTool/searchFeature/
Exception Value: 'RelatedObject' object has no attribute 'unique'


--
Thiago

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Odd problem with date based generic views

2009-01-19 Thread phoebebright

Just going to transfer the view into a real table.  Will let you know
if that doesn't solve the problem!

On Jan 19, 12:57 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-01-19 at 04:38 -0800, phoebebright wrote:
> > Generic view - year_archive, is not working for me.  There are no
> > errors displayed and no data either.  On investigation, there seems to
> > be a mysql error that is causing the problem and it could be related
> > to the my using a view instead of a table as the source for the mode.
> > The original date field is not a date but is converted to a date in
> > the view and maybe this is the problem.
>
> [...]
>
> > If I run the query manually in mysql and add quotes around the range
> > values,
>
> > BETWEEN '2007-01-01 00:00:00' and '2007-12-31 23:59:59.99'
>
> > it works fine but not without the quotes.
>
> > This may be a red herring - the toolbar might be stripping quotes from
> > the query.
>
> Yes, that is a red herring. It's not the debug toolbar, but a limitation
> of the Python DB wrappers. There's no public API to ask them how they
> are about to quote parameters. So the strings you get from
> django.db.connection.queries (which is what the debug toolbar is showing
> you) are the query strings with the parameter values substituted in for
> the "%s" placeholders. It's actually the raw_sql string that is passed
> to the DB wrapper (MySQLdb in your case), along with a couple of Python
> objects for the parameters. It takes care of quoting things correctly
> and feeding the resulting string to the database correctly.
>
> Everything you've written looks right. So I'd be suspicious of your
> database view, as you are.
>
> As you deduce, if we broke archive_year at any point, I suspect it would
> take about 23 seconds before somebody reported the bug. Generic views
> tend to get used a lot. :-)
>
> 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: Odd problem with date based generic views

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 04:38 -0800, phoebebright wrote:
> Generic view - year_archive, is not working for me.  There are no
> errors displayed and no data either.  On investigation, there seems to
> be a mysql error that is causing the problem and it could be related
> to the my using a view instead of a table as the source for the mode.
> The original date field is not a date but is converted to a date in
> the view and maybe this is the problem.


[...]
> If I run the query manually in mysql and add quotes around the range
> values,
> 
> BETWEEN '2007-01-01 00:00:00' and '2007-12-31 23:59:59.99'
> 
> it works fine but not without the quotes.
> 
> This may be a red herring - the toolbar might be stripping quotes from
> the query.

Yes, that is a red herring. It's not the debug toolbar, but a limitation
of the Python DB wrappers. There's no public API to ask them how they
are about to quote parameters. So the strings you get from
django.db.connection.queries (which is what the debug toolbar is showing
you) are the query strings with the parameter values substituted in for
the "%s" placeholders. It's actually the raw_sql string that is passed
to the DB wrapper (MySQLdb in your case), along with a couple of Python
objects for the parameters. It takes care of quoting things correctly
and feeding the resulting string to the database correctly.

Everything you've written looks right. So I'd be suspicious of your
database view, as you are.

As you deduce, if we broke archive_year at any point, I suspect it would
take about 23 seconds before somebody reported the bug. Generic views
tend to get used a lot. :-)

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



Geraldo - reports engine

2009-01-19 Thread Marinho Brandao

Hi folks,

I am working in a reports engine, with name "Geraldo". It is working
well and I will finish the missing things for a first version tonight
or tomorrows night.

Its repository is here:

- http://github.com/marinho/django-geraldo/

For a while it is generating only PDF, is a ReportLab and PIL
dependent and supports the most important things in reports:

- report top/begin band
- report summary
- page header
- page footer
- detail band
- child bands attaching
- aggregations
- visible/invisible bands and elements
- system variables
- calculated/expression fields
- margins/page sizes
- basic graphic canvas elements (circles, ellipses, PIL or file
images, arcs, lines, etc)
- elements style
- and so on

there are two missing things to have a first good API:

- subreports
- groupping

tests with example codes and PDFs are in the folter "tests" in the
latest commit, here for example:

- 
http://github.com/marinho/django-geraldo/tree/8e2c7f344957d1c85a4ee59b949fabe5d6ca9e59/geraldo/tests

in future I want to make HTML and other formats generation and maybe a
GUI editor, like iReport.

bugs reporting, suggestions and contributing are welcome :) hugs

-- 
Marinho Brandão (José Mário)
http://marinhobrandao.com/

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



Odd problem with date based generic views

2009-01-19 Thread phoebebright

Generic view - year_archive, is not working for me.  There are no
errors displayed and no data either.  On investigation, there seems to
be a mysql error that is causing the problem and it could be related
to the my using a view instead of a table as the source for the mode.
The original date field is not a date but is converted to a date in
the view and maybe this is the problem.

Using generic views as in tutorial:

info_dict = {
'queryset': Task.objects.all(),
'date_field': 'entry_date',
'template_object_name' : "tasks",

}

urlpatterns += patterns('django.views.generic.date_based',
   (r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?P[-
\w]+)/$', 'object_detail', info_dict),
   (r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/
$',   'archive_day',   info_dict),
   (r'^(?P\d{4})/(?P[a-z]{3})/
$','archive_month', info_dict),
   (r'^(?P\d{4})/
$',
'archive_year',  info_dict),
   (r'^
$',
'archive_index', info_dict),
)

Template task_archive_year.html

{% for object in tasks  %}
{{ object.task }}
{{ object.list }} 
{% endfor %}


As far as I can see, mysql is failing on this query - info copied from
debugger toolbar:

  'raw_sql': u"SELECT DISTINCT CAST(DATE_FORMAT
(`tasks`.`entry_date`, '%%Y-%%m-01 00:00:00') AS DATETIME) FROM
`tasks` WHERE `tasks`.`entry_date` BETWEEN %s and %s ORDER BY 1 ASC",
  'sql': u"SELECT\n\tDISTINCT CAST(DATE_FORMAT
(`tasks`.`entry_date`, '%Y-%m-01 00:00:00') AS DATETIME) FROM `tasks`
\nWHERE\n\t`tasks`.`entry_date` BETWEEN 2007-01-01 00:00:00 and
2007-12-31 23:59:59.99\nORDER BY\n\t1 ASC",

If I run the query manually in mysql and add quotes around the range
values,

BETWEEN '2007-01-01 00:00:00' and '2007-12-31 23:59:59.99'

it works fine but not without the quotes.

This may be a red herring - the toolbar might be stripping quotes from
the query.  And since I can find nobody else with this problem, I
suspect it is something to do with my views - or I've done something
really stupid again!

Am running MySQL 5.0.24a-standard on OSX.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Possible to see sql for queryset before database gets it?

2009-01-19 Thread phoebebright

Thanks for those tips.  Great help.

On Jan 19, 12:37 am, Malcolm Tredinnick 
wrote:
> On Sun, 2009-01-18 at 17:46 -0200, Ramiro Morales wrote:
>
> []
>
>
>
> > or if you are using a recent trunk version (more recent than two weeks or 
> > so)
> > you might want to try printing the output of:
>
> > .as_sql()
>
> Please don't recommend that one, it's very likely to change in the near
> future (like, this week some time), as I'm becoming unhappy with the
> name choice for the reasons given below.
>
> I was trying to keep the internal code clean by not having to if-case
> yet another method name.. The problem with the current method name is
> that it leaks the "SQL" concept into QuerySets, which should, ideally,
> be agnostic about what the storage method is. Unnecessarily leaky
> abstraction and it's keeping me awake at night.
>
> Every QuerySet that has some kind of backing store should have a "query"
> attribute and, if it supports SQL, will have an as_sql() method. (The
> previous sentence is written in a very future-proof fashion. It's
> trivially true for Django at the moment.) The queryset.query.as_sql()
> method is the best way to look at the generated SQL.
>
> 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: I am doing the tutorial part 1 and i got this error

2009-01-19 Thread Herson

More attention, python is case sensitive.

model is different of Model.

2009/1/19, joti chand :
>
>  Thanks mate
>
>
>  On Mon, Jan 19, 2009 at 9:26 PM, Eric Abrahamsen  wrote:
>  >
>  >
>  > On Jan 19, 2009, at 4:17 PM, jazz wrote:
>  >
>  >>
>  >> c:\projects\mysite>python manage.py sql polls
>  >> Traceback (most recent call last):
>  >>  File "manage.py", line 11, in 
>  >>execute_manager(settings)
>  >>  File "C:\Python25\Lib\site-packages\django\core\management
>  >> \__init__.py", line 340, in execute_manager
>  >>utility.execute()
>  >>  File "C:\Python25\Lib\site-packages\django\core\management
>  >> \__init__.py", line 295, in execute
>  >>self.fetch_command(subcommand).run_from_argv(self.argv)
>  >>  File "C:\Python25\Lib\site-packages\django\core\management\base.py",
>  >> line 195, in run_from_argv
>  >>self.execute(*args, **options.__dict__)
>  >>  File "C:\Python25\Lib\site-packages\django\core\management\base.py",
>  >> line 221, in execute
>  >>self.validate()
>  >>  File "C:\Python25\Lib\site-packages\django\core\management\base.py",
>  >> line 249, in validate
>  >>num_errors = get_validation_errors(s, app)
>  >>  File "C:\Python25\lib\site-packages\django\core\management
>  >> \validation.py", line 28, in get_validation_errors
>  >>for (app_name, error) in get_app_errors().items():
>  >>  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
>  >> line 128, in get_app_errors
>  >>self._populate()
>  >>  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
>  >> line 57, in _populate
>  >>self.load_app(app_name, True)
>  >>  File "C:\Python25\lib\site-packages\django\db\models\loading.py",
>  >> line 72, in load_app
>  >>mod = __import__(app_name, {}, {}, ['models'])
>  >>  File "c:\projects\mysite\..\mysite\polls\models.py", line 4, in
>  >> 
>  >>class Poll(models.model):
>  >> AttributeError: 'module' object has no attribute 'model'
>  >>
>  >
>  > Capitalization is important, you want to subclass models.Model, not
>  > models.model.
>  >
>  > That should do the trick,
>  >
>  > Eric
>  >
>  >
>  >> This is wat i did:
>  >>
>  >> from django.db import models
>  >>
>  >> # Create your models here.
>  >> class Poll(models.model):
>  >>question = models.CharField(max_length=200)
>  >>pub_date = models.DateTimeField('date published')
>  >>
>  >> class Choice(models.Model):
>  >>poll = models.ForeignKey(Poll)
>  >>choice = models.CharField(max_length=200)
>  >>votes = models.IntegerField()
>  >> >
>  >
>  >
>  > >
>  >
>
>  >
>


-- 
Herson Leite




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: FileBrowser: Easy access to generated images from the template?

2009-01-19 Thread Benjamin Buch

Thank you!

I guess I'll wait...

Benjamin

Am 19.01.2009 um 10:30 schrieb patrickk:

>
> you could either use a templatetag or a custom-method.
>
> that said, we are just working on integrating this with the  
> filebrowse-
> field. so, if you wait a couple of days it´ll be there.
>
> here´s more information: 
> http://code.google.com/p/django-filebrowser/issues/detail?id=63
>
> patrick.
>
>
> On Jan 18, 1:52 pm, Benjamin Buch  wrote:
>> I'm using django-filebrowser(http://code.google.com/p/django-filebrowser/
>> ) to upload and manage files within my project.
>> And it's working great!Filebrowseris a great app.
>>
>> The only problem I'm having is this:
>> I coupledfilebrowserwith on of my models ('News') and use the
>> FileBrowse-Field for this 
>> (http://code.google.com/p/django-filebrowser/wiki/installationfilebrow 
>> ...
>> ),
>> and I like filebrowsers' image generator and want to use it.
>>
>> But how can I access the generated images from the template?
>> Say I have the template variable 'news_report' in my template and  
>> want
>> to display the image, I would write
>>
>> 
>>
>> That would give me the original image, not the processed one.
>> The url for the original image is something like
>>
>> '/media/uploads/news/DSC04678.JPG',
>>
>> and the url to the processed version would be something like
>>
>> '/media/uploads/news/dsc04678_jpg_versions/cropped_DSC04678.JPG'
>>
>> Is there a way to access the url to the processed image from the
>> template?
>>
>> Benjamin
> 

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

2009-01-19 Thread Dj Gilcrease

On Mon, Jan 19, 2009 at 2:58 AM, joti chand  wrote:
>
> anyone knows is there any blog site development example in django


There are lots and lots of blog apps for django

http://getbanjo.com/
http://code.google.com/p/django-basic-apps/
http://byteflow.su/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: What am i doing here

2009-01-19 Thread Dj Gilcrease

On Mon, Jan 19, 2009 at 1:55 AM, joti chand  wrote:
>
> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] 
> on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
 from mysite.polls.models import Poll, Choice
> Traceback (most recent call last):
>  File "", line 1, in 
> ImportError: No module named mysite.polls.models


The error tells you exactly whats wrong. It could not find
mysite.polls.models. There could be several reasons for this
1) mysite is not on the python path. To test try import mysite
2) there is no __init__.py in the polls directory. If 1 passes then
try import mysite.polls
3) there is no models.py or models package (in simple terms a package
is a directory with an __init__.py file). If both 1 & 2 pass then try
import mysite.polls.models

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



Re: building a blog site

2009-01-19 Thread Muslu Yüksektepe
i am preparing a blog site.
check out www.yuksektepe.com
i will add how can make blog as soon as
thank you
from Turkiye

2009/1/19 joti chand 

>
> anyone knows is there any blog site development example in django
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Kenneth Gonsalves

On Monday 19 Jan 2009 3:01:29 pm jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined

you need to import datetime

-- 
regards
KG
http://lawgon.livejournal.com

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



building a blog site

2009-01-19 Thread joti chand

anyone knows is there any blog site development example in django

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 01:31 -0800, jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined
> 
> any help

This is the third time in a couple of hours that you've posted something
like this. So, a couple of items of general advice. Please take them in
the spirit they're offered:

(1) Just posting the very last line on the screen is not that helpful.
It's like reporting there's a car crash without mentioning where it is
or that you happened to be the driver. We don't have enough information
to say anything intelligent beyond "you haven't given us enough
information." It happens, from having seen lots of questions, that I can
guess you're working through the first part of the tutorial, but you're
not always going to be that lucky.

(2) The tutorial is not fundamentally broken. Thousands of people have
worked through it successfully. So if you're seeing things that appear
to be basic errors, like the above, go back a few steps, re-read things
and try to find what you've missed. All of the information needed to
construct the examples are in the tutorial text.

For example, the above error suggests you've omitted the "import
datetime" line. That is on the line exactly one line above where you're
seeing the error. So you don't have to look back very far to find the
problem in this case. You've already seen that case-sensitivity is
important (in an earlier message) and that not missing lines (in this
case) is important. So, please take your time. If you end up posting 6
or 12 messages a day, you're going to find that people simply don't have
the time or inclination to help you, because you're not taking the time
to help yourself first.

We're very helpful on this list, providing you realise you are one of
well over 10,000 people on a very high-volume list. You have to do some
reasonable level of homework/preparation before posting.

In any case, it's nice to see another person trying out Django. It might
well require a little getting used to, since you're also trying to learn
Python at the same time (I would *strongly* recommend working through
the Python tutorial at python.org, at a minimum, before starting to work
with Django, but people are free to attempt anything), but it's
generally a fun experience once you put in the necessary study time.

Regards,
Malcolm



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



NameError: global name ‘datetime’ is not defined

2009-01-19 Thread jazz

p.was_published_today() Traceback (most recent call last):
File "", line 1, in File "c:\projects\mysite..\mysite\polls
\models.py", line 11, in was_published_today return self.pub_date.date
() == datetime.date.today() NameError: global name 'datetime' is not
defined

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



  1   2   >