Re: What apps or snippets to use for Facebook and Twitter registration, login and posting?

2011-03-03 Thread Tomasz Zieliński


On 2 Mar, 18:30, Jason Culverhouse  wrote:
> On Mar 2, 2011, at 8:28 AM, Rodrigo Cea wrote:
>
> > I am developing a site that I want to link with Facebook and Twitter.
>
> https://github.com/flashingpumpkin/django-socialregistration(note the forks)
>

Personally I like django-socialregistration, it fits my brain
circuits more than other packages - which of course is a subjective
recommendation.

One thing to note is that JavaScript-based FB Connect is very tricky
to use
if you want to rely your user authentication on it - it's more suited
for sites
where user merely connects tab with the site to tab with FB, to post
some wall posts.

--
Tomasz Zielinski
pyconsultant.eu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Vladimir
1. web browser does not give messages, in command line I see:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 280, in run
self.result=application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 709, in __call__
mime_type=mimetypes.guess_type(file_path)[0]
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in
read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in  enum_types
ctype=ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
0: ordinal not in range(128)

2. mysite\blog\models.py:
# -*- coding: utf-8 -*-

from django.db import models
from django.contrib import admin

class BlogPost(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()

class Meta:
ordering = ('-timestamp',)

class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



AW: UnicodeDecodeError: 'ASCII' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Szabo, Patrick (LNG-VIE)
If you want to see errors in the browser you might want to set "DEBUG = True" 
in your settings.py

Kind regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Vladimir
Gesendet: Donnerstag, 03. März 2011 10:01
An: Django users
Betreff: Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in 
position 0: ordinal not in range(128)

1. web browser does not give messages, in command line I see:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 280, in run
self.result=application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 709, in __call__
mime_type=mimetypes.guess_type(file_path)[0]
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in
read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in  enum_types
ctype=ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
0: ordinal not in range(128)

2. mysite\blog\models.py:
# -*- coding: utf-8 -*-

from django.db import models
from django.contrib import admin

class BlogPost(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()

class Meta:
ordering = ('-timestamp',)

class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread Sam Lai
On 3 March 2011 08:02, Alex Hall  wrote:
> Hi all,
> Still working through that tutorial. I am just curious: why are none
> of the class variables called self.var, but rather just var? For
> example:
> import models
> class Poll(models.Model):
>  question=models.CharField(max_length=200)
>
> Should that not be
> self.question=...
> instead? Otherwise, saying something like:
> poll=Poll()
> poll.question="question?"
> should not work; question is not told to be part of the class by way
> of self. This may stray from django and into pure python territory, so
> sorry if it gets off-topic. I have never seen a class that does not
> tie its variables to itself with self or some other keyword. Come to
> think of it, there is no __init__ method. I know that it is not
> necessary to have one, but I figured I would have seen one to get
> things set up.

Django uses the magic of metaclasses to build model instances - see
http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L26

> --
> Have a great day,
> Alex (msg sent from GMail website)
> mehg...@gmail.com; http://www.facebook.com/mehgcap
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: oAuth 2.0

2011-03-03 Thread Олег Корсак
Yes. But I'm stuck with first step... As I understood - first of all I need to 
ask for request_token from my server. Done this. But what kind of token and how 
server needs to return? 
- Исходное сообщение -
> In the README for python-oauth2
> (https://github.com/simplegeo/python-oauth2) there is a good example in
> the "Logging into Django w/ Twitter" section.
> 
> 
> 
> 
> _Mick
> On Wednesday, March 2, 2011 at 2:36 PM, Олег Корсак wrote: 
> > hello. Is there any tutorial/example about oAuth 2.0 built into Django
> > and through python-oauth2-1.2.1 ? thanks
> > 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group. To post to this group, send email to
> django-users@googlegroups.com. To unsubscribe from this group, send
> email to django-users+unsubscr...@googlegroups.com. For more options,
> visit this group at http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ASCII' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Vladimir


On 3 мар, 12:10, "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> If you want to see errors in the browser you might want to set "DEBUG = True" 
> in your settings.py
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146
>
> -Ursprüngliche Nachricht-
>
> Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
> Auftrag von Vladimir
> Gesendet: Donnerstag, 03. März 2011 10:01
> An: Django users
> Betreff: Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in 
> position 0: ordinal not in range(128)
>
> 1. web browser does not give messages, in command line I see:
> Traceback (most recent call last):
> File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
> line 280, in run
>     self.result=application(self.environ, self.start_response)
> File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
> line 709, in __call__
>     mime_type=mimetypes.guess_type(file_path)[0]
> File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
>     init()
> File "C:\Python27\lib\mimetypes.py", line 355, in init
>     db.read_windows_registry()
> File "C:\Python27\lib\mimetypes.py", line 259, in
> read_windows_registry
>     for ctype in enum_types(mimedb):
> File "C:\Python27\lib\mimetypes.py", line 249, in  enum_types
>     ctype=ctype.encode(default_encoding) # omit in 3.x!
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
> 0: ordinal not in range(128)
>
> 2. mysite\blog\models.py:
> # -*- coding: utf-8 -*-
>
> from django.db import models
> from django.contrib import admin
>
> class BlogPost(models.Model):
>     title = models.CharField(max_length=150)
>     body = models.TextField()
>     timestamp = models.DateTimeField()
>
>     class Meta:
>         ordering = ('-timestamp',)
>
> class BlogPostAdmin(admin.ModelAdmin):
>     list_display = ('title', 'timestamp')
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread Stefano
self in not a keyword in python, is only a convention for the first
parameter for bound method. It
refers to the instance of the class so you cannot use in the class definition.
You should read something about "bound" and "unbound" methods in python.

Hope this help

S.


2011/3/2 Alex Hall :
> Hi all,
> Still working through that tutorial. I am just curious: why are none
> of the class variables called self.var, but rather just var? For
> example:
> import models
> class Poll(models.Model):
>  question=models.CharField(max_length=200)
>
> Should that not be
> self.question=...
> instead? Otherwise, saying something like:
> poll=Poll()
> poll.question="question?"
> should not work; question is not told to be part of the class by way
> of self. This may stray from django and into pure python territory, so
> sorry if it gets off-topic. I have never seen a class that does not
> tie its variables to itself with self or some other keyword. Come to
> think of it, there is no __init__ method. I know that it is not
> necessary to have one, but I figured I would have seen one to get
> things set up.
>
> --
> Have a great day,
> Alex (msg sent from GMail website)
> mehg...@gmail.com; http://www.facebook.com/mehgcap
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ASCII' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Vladimir
Thank You very much!
It is set by default but there is no error message. Some days ago,
when I had another problem, web browser showed messages.


On 3 мар, 12:10, "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> If you want to see errors in the browser you might want to set "DEBUG = True" 
> in your settings.py
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



JavaScript Parameter

2011-03-03 Thread Szabo, Patrick (LNG-VIE)
Hi, 

I finally found a JavaScript that gives me autosuggest functionality for
a textfield.
Unfortunately this script uses a hard-coded array for the suggestions
and of courese i want to use values from my database.

Any idea how i could pass the javascript an array that contains all my
values ?!

Im calling the script like this in my template: 

Kind regards

. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Form/view for ManyToMany relationship

2011-03-03 Thread kgardenia42
Hi list,

Considering this schema (below) I'm trying to figure out how to create
a ModelForm which links Actors to Films (all known actors in a multi-
select widget).  I can't seem to figure out how to do this in a way
that ModelForm will do the heavy lifting.

I would like to make a page (e.g. /film/add_actors/123) that has a
multi select widget which allows me to select one or more Actors (from
a list of all possible actors) and link them to the given film object.

Is ModelForm the right thing to use here?

I'm going to outline what I've tried to give context.

If I simply do this:

class FilmRoleForm(forms.ModelForm):
class Meta:
model = FilmRole
fields = (('actor'),)

Then it only gives me a form to populate one row in FilmRole (I know I
have to manually munge the other fields but I can handle that).

That behaviour makes sense.   However, it isn't the behaviour I want.
I want to be able to populate many rows at once (since a film can have
many actors).

So I tried this:

class FilmRoleForm(forms.ModelForm):
actor = forms.ModelMultipleChoiceField(
widget=forms.SelectMultiple,
queryset = Actor.objects.all()
)

class Meta:
model = FilmRole
fields = (('actor'),)

ok - progress.  Now I get the widget I want (a multi select list) but
when I submit it I get an exception like this:

Cannot assign "[, ]":
"FilmRole.actor" must be a "Actor" instance.

Again, I can see why this is but it isn't the behaviour I want.

How can I tell Django "use a multi-select widget and I expect a list
of values not a single (non list) value".

Assuming I were able to circumvent that problem, I'm also trying to
avoid having to write code like this in the view:

for actor in form.cleaned_data.get('actor'):
FilmRole.get_or_create(actor = actor, film = film)

... that isn't so bad but it also requires that I keep track of rows I
need to delete (those FilmRole objects in the database from previous
submits that have been unselected in the latest
form.cleaned_data.get('actor'))

I'd just like all that behaviour be implicit somehow.  I know that
when my mapping table (FilmRole) is implicitly created and doesn't
have extract fields then Django can handle all that magically.   Is
there some other variant of ModelForm that can handle this?

Any suggestions are most welcome.

Thanks.

#


class Actor(models.Model):
name = models.CharField(max_length=255)
dob = models.DateField()

def __unicode__(self):
return self.name

class Film(models.Model):
title = models.CharField(max_length=255)
actors = models.ManyToManyField(Actor, through = 'FilmRole')
released = models.DateField()

def __unicode__(self):
return self.title

class FilmRole(models.Model):
film = models.ForeignKey(Film)
actor = models.ForeignKey(Actor)
date_joined = models.DateField()
earnings = models.IntegerField()

class Meta:
unique_together = ("film", "actor")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Upgrade question

2011-03-03 Thread Niklasro
Hi dear group, could you comment on the following I'd very much
appreciate the knowledge:

On Wed, Mar 2, 2011 at 11:50 PM, Niklasro  wrote:
> Hi
> I got problems with escape displaying like junk when upgrading from
> django 0.96 to 1.2 with google app engine.
> The code is
>
> # let user choose authenticator
>for p in openIdProviders:
>p_name = p.split('.')[0] # take "AOL" from "AOL.com"
>p_url = p.lower()# "AOL.com" -> "aol.com"
>loginmsg = loginmsg + '%s ' % ( #'','')
>   users.create_login_url(federated_identity=p_url),
> p_name)
>loginmsg = loginmsg + '%s' %
> ('login',_("Log in"))
>
> And the output is strange. View source show this:
>
> Add03 Mar
>
> Log inGoogle  href="google.com">Yahoo  href="google.com">MySpace  href="google.com">AOL  href="login">Log in
>
> 
>
> Can you make ad advice how to proceed? Many thanks,

IIRC, at some point after v0.96, Django made
HTML-character-entity-escaping of values in templates the default
behavior; your code assumes the opposite, hence your excessive
escaping problem. I'm sure there's a way to indicate that certain
values should be treated literally and not get HTML-escaped.

Check the transition docs / release notes, and/or try asking on the
django-specific mailing list
(http://groups.google.com/group/django-users )
(You should probably ask there first with any future Django questions
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.



Override default django Registration email

2011-03-03 Thread pols
hai
 Anyone knows how to override djangos default registration email.I
need to alter it to sent as html email instead of text email.As i am a
bigner of django help me with complete information

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



Re: Upgrade question

2011-03-03 Thread bruno desthuilliers
On 3 mar, 09:21, Niklasro  wrote:
> Hi dear group, could you comment on the following I'd very much
> appreciate the knowledge:
>
>
>
> > Hi
> > I got problems with escape displaying like junk when upgrading from
> > django 0.96 to 1.2 with google app engine.
> > The code is
>
> >     # let user choose authenticator
> >        for p in openIdProviders:
> >            p_name = p.split('.')[0] # take "AOL" from "AOL.com"
> >            p_url = p.lower()        # "AOL.com" -> "aol.com"
> >            loginmsg = loginmsg + '%s ' % ( #'','')
> >                   users.create_login_url(federated_identity=p_url),
> > p_name)
> >        loginmsg = loginmsg + '%s' %
> > ('login',_("Log in"))

Slightly OT but I wouldnt' build html this way in Django. We do have
templates, don't we ?-)


> > And the output is strange. View source show this:
>
> > Log inGoogle  > href="google.com">Yahoo  > href="google.com">MySpace  > href="google.com">AOL  > href="login">Log in

http://docs.djangoproject.com/en/1.2/releases/1.0-porting-guide/#learn-to-love-autoescaping

I strongly suggest you read the whole page FWIW.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Override default django Registration email

2011-03-03 Thread Kenneth Gonsalves
On Thu, 2011-03-03 at 00:36 -0800, pols wrote:
> Anyone knows how to override djangos default registration email.I
> need to alter it to sent as html email instead of text email.As i am a
> bigner of django help me with complete information
> 
> 

copy the templates to a folder called registration in your project and
modify it how you like
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread bruno desthuilliers

On 2 mar, 22:02, Alex Hall  wrote:
> Hi all,
> Still working through that tutorial. I am just curious: why are none
> of the class variables called self.var, but rather just var? For
> example:
> import models
> class Poll(models.Model):
>  question=models.CharField(max_length=200)


What you define here is a class attribute, not an instance attribute.
FWIW, Django models do some metaprogramming magic with the models
fields, but that's rather advanced Python programming. You'll have to
read about Python's object model, metaclasses and descriptors if you
really want to understand what's going on here.

> Should that not be
> self.question=...
> instead?

"self" is nothing magical, it's just a coding convention for functions
meant to be used as bound methods. You could replace it with "parrot"
in your code, it would work just the same. So, "self" is only a name
like any other, usually used to refer to the object the function's
code is working on. This instance is passed to the function like any
other argument (even if there's some other metaprogramming magic
happening here). myobj.method() is just a convenient shortcut for
myobj.__class__.method(myobj) - and that's indeed what really happens.


> Otherwise, saying something like:
> poll=Poll()
> poll.question="question?"
> should not work;


For which definition of "should not work" ?-)

Python is a dynamic language. You can add / replace / remove instance
or class attributes (almost) at will:
>>> class Foo(object):
... pass
...
>>> f = Foo()
>>> f.bar = 42
>>> f.bar
42
>>> f2 = Foo()
>>> f2.bar
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Foo' object has no attribute 'bar'
>>> del f.bar
>>> f.bar
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Foo' object has no attribute 'bar'
>>>

> question is not told to be part of the class by way
> of self.

'poll.question' is an ordinary instance attribute. The "question"
attribute defined in the Poll class is something very different.

> This may stray from django and into pure python territory,

Well, Django is a Python framework, so to understand Django you have
to understand Python...

> so
> sorry if it gets off-topic. I have never seen a class that does not
> tie its variables to itself

Looks like you're confusing class and instance. Every name defined at
the top level of a class statement's block become an attribute of the
class itself (yes, Python classes are objects too) - unless the
class's class (aka metaclass) do something weird with it when the
class statement is eval'd.


> with self or some other keyword.

self is NOT a keyword.

> Come to
> think of it, there is no __init__ method. I know that it is not
> necessary to have one, but I figured I would have seen one to get
> things set up.


There's of course a __init__ method, in the models.Model base class.
One of the nice things with Django is that it's opensource. This means
that you have the whole source code and the right to read it ;)

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



Re: Override default django Registration email

2011-03-03 Thread pols


On Mar 3, 1:36 pm, pols  wrote:
> hai
>      Anyone knows how to override djangos default registration 
> email(activation email).I
> need to alter it to sent as HTML email instead of TEXT email.ie i need to 
> send my activation_email.html template  intead of default template 
> activation_emai.txt As i am a
> bigner of django help me with complete information

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



Re: Override default django Registration email

2011-03-03 Thread bruno desthuilliers
On 3 mar, 13:39, Kenneth Gonsalves  wrote:
> On Thu, 2011-03-03 at 00:36 -0800, pols wrote:
> > Anyone knows how to override djangos default registration email.I
> > need to alter it to sent as html email instead of text email.As i am a
> > bigner of django help me with complete information
>
> copy the templates to a folder called registration in your project and
> modify it how you like

If the OP is talking about django-registration, overriding the
templates will not be enough, as
RegistrationProfile.send_activation_email sends plain text mails.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Karen Tracey
On Thu, Mar 3, 2011 at 4:01 AM, Vladimir  wrote:

> 1. web browser does not give messages, in command line I see:
> Traceback (most recent call last):
> File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
> line 280, in run
>self.result=application(self.environ, self.start_response)
> File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
> line 709, in __call__
>mime_type=mimetypes.guess_type(file_path)[0]
> File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
>init()
> File "C:\Python27\lib\mimetypes.py", line 355, in init
>db.read_windows_registry()
> File "C:\Python27\lib\mimetypes.py", line 259, in
> read_windows_registry
>for ctype in enum_types(mimedb):
> File "C:\Python27\lib\mimetypes.py", line 249, in  enum_types
>ctype=ctype.encode(default_encoding) # omit in 3.x!
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
> 0: ordinal not in range(128)
>

This looks like a bug in Python. Traceback is showing Python mimetypes
init() trying to read the windows registry and running into trouble. The
code in question isn't even using any parameters passed in from the Django
code calling it, so it's unlikely any change to Django (other than not using
mimetypes guess_type) would help to fix it.

This has come up before on this list, and a workaround was mentioned here:

http://groups.google.com/group/django-users/msg/7fe07998db471693

A real fix I believe would need to be made to the Python library code to
ensure that it doesn't die if the windows registry contains non-ASCII data.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Override default django Registration email

2011-03-03 Thread pols


hai i need to send my activation_email.html template instead of
activattion_email.txt.By default django sends only text emails as the
activation mail.But i need to send this as html.so i need to override
that email sending function.but i dont know how?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread Alex Hall
Thanks everyone. Looks like I have reading to do...

On 3/3/11, bruno desthuilliers  wrote:
>
> On 2 mar, 22:02, Alex Hall  wrote:
>> Hi all,
>> Still working through that tutorial. I am just curious: why are none
>> of the class variables called self.var, but rather just var? For
>> example:
>> import models
>> class Poll(models.Model):
>>  question=models.CharField(max_length=200)
>
>
> What you define here is a class attribute, not an instance attribute.
> FWIW, Django models do some metaprogramming magic with the models
> fields, but that's rather advanced Python programming. You'll have to
> read about Python's object model, metaclasses and descriptors if you
> really want to understand what's going on here.
>
>> Should that not be
>> self.question=...
>> instead?
>
> "self" is nothing magical, it's just a coding convention for functions
> meant to be used as bound methods. You could replace it with "parrot"
> in your code, it would work just the same. So, "self" is only a name
> like any other, usually used to refer to the object the function's
> code is working on. This instance is passed to the function like any
> other argument (even if there's some other metaprogramming magic
> happening here). myobj.method() is just a convenient shortcut for
> myobj.__class__.method(myobj) - and that's indeed what really happens.
>
>
>> Otherwise, saying something like:
>> poll=Poll()
>> poll.question="question?"
>> should not work;
>
>
> For which definition of "should not work" ?-)
>
> Python is a dynamic language. You can add / replace / remove instance
> or class attributes (almost) at will:
 class Foo(object):
> ... pass
> ...
 f = Foo()
 f.bar = 42
 f.bar
> 42
 f2 = Foo()
 f2.bar
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'Foo' object has no attribute 'bar'
 del f.bar
 f.bar
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'Foo' object has no attribute 'bar'

>
>> question is not told to be part of the class by way
>> of self.
>
> 'poll.question' is an ordinary instance attribute. The "question"
> attribute defined in the Poll class is something very different.
>
>> This may stray from django and into pure python territory,
>
> Well, Django is a Python framework, so to understand Django you have
> to understand Python...
>
>> so
>> sorry if it gets off-topic. I have never seen a class that does not
>> tie its variables to itself
>
> Looks like you're confusing class and instance. Every name defined at
> the top level of a class statement's block become an attribute of the
> class itself (yes, Python classes are objects too) - unless the
> class's class (aka metaclass) do something weird with it when the
> class statement is eval'd.
>
>
>> with self or some other keyword.
>
> self is NOT a keyword.
>
>> Come to
>> think of it, there is no __init__ method. I know that it is not
>> necessary to have one, but I figured I would have seen one to get
>> things set up.
>
>
> There's of course a __init__ method, in the models.Model base class.
> One of the nice things with Django is that it's opensource. This means
> that you have the whole source code and the right to read it ;)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com; http://www.facebook.com/mehgcap

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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 apps or snippets to use for Facebook and Twitter registration, login and posting?

2011-03-03 Thread guyf


On Mar 2, 4:28 pm, Rodrigo Cea  wrote:
> I am developing a site that I want to link with Facebook and Twitter.
>
> So as to not reinvent the wheel, I'm looking for apps or snippets that can
> help with this, specifically:
>
> 1) allow users to register and login with their Facebook and/or Twitter
> accounts.
>
> 2) Have these accounts be linked to the local one (crossposting to their FB
> and Twitter account, pulling in their posts on FB and TW, etc.)
>
> Thanks,
>
> Rodrigo

Hi Roderigo,

I have recently done this for facebook and used
http://code.google.com/p/django-facebookconnect/. I started with
django-socialauth but as a newcomer to django and python I got myself
in a tangle so unwound it and went for the simpler facebookconnect
options. Downside is it is only facebook.

Guy.

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



Re: What apps or snippets to use for Facebook and Twitter registration, login and posting?

2011-03-03 Thread Addy Yeow
For Twitter, https://github.com/joshthecoder/tweepy does the trick for me.

On Thu, Mar 3, 2011 at 9:51 PM, guyf  wrote:
>
>
> On Mar 2, 4:28 pm, Rodrigo Cea  wrote:
>> I am developing a site that I want to link with Facebook and Twitter.
>>
>> So as to not reinvent the wheel, I'm looking for apps or snippets that can
>> help with this, specifically:
>>
>> 1) allow users to register and login with their Facebook and/or Twitter
>> accounts.
>>
>> 2) Have these accounts be linked to the local one (crossposting to their FB
>> and Twitter account, pulling in their posts on FB and TW, etc.)
>>
>> Thanks,
>>
>> Rodrigo
>
> Hi Roderigo,
>
> I have recently done this for facebook and used
> http://code.google.com/p/django-facebookconnect/. I started with
> django-socialauth but as a newcomer to django and python I got myself
> in a tangle so unwound it and went for the simpler facebookconnect
> options. Downside is it is only facebook.
>
> Guy.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Perses Titan
Hello!

I got the same error when i tried to work with Cyrillic charset in
Python.
In my case it was pure Python problem.
Here is good explanation why it happened: 
http://docs.python.org/howto/unicode.html
and  http://python.su/forum/viewtopic.php?pid=6476 (rus)

In your case, most probably django crashs when it reads nonASCII
characters from DB.


Wadim.


On 3 мар, 08:48, Vladimir  wrote:
> Good morning!
> In me first exercise project with Django I met an error message:
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position
> 0: ordinal not in range(128). Admin pages are built without css.
> Then I changed all .py-files entering
> # -*- coding: utf-8 -*-
> into the first row and recreated database:
> ALTER DATABASE `djangodb` DEFAULT CHARACTER SET utf-8 COLLATE
> utf8_unicode_ci
> I also tryed COLLATE utf8_swedish_ci. Then I recreated tables with
> manage.py syncdb.
> No effect. Is this a typical problem of Django beginners?
> I need only russian and english languages in my projects endeed.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Karen Tracey
On Thu, Mar 3, 2011 at 8:57 AM, Perses Titan  wrote:

> In your case, most probably django crashs when it reads nonASCII
> characters from DB.
>
>
No. The posted traceback clearly shows where the error is occurring and it
is nowhere in Django. As I posted earlier it looks like a bug in the Python
library. I'd also guess it is new with Python 2.7 since I cannot recall
seeing this problem posted before Python 2.7 came out. The right place to
pursue this particular problem is in the Python bug tracker -- for all I
know it has already been noted and fixed, I have not attempted to track it
down from that side.

Django fully supports non-ASCII data in the database, in template files,
dynamically generated by application code. (Your application, of course,
must ALSO be coded to properly handled non-ASCII data.)

Posting that Django probably crashed when reading non-ASCII data from the
database is misleading and in this case where the traceback was posted
flat-out wrong.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread kost BebiX
Yes, that's more a Python problem, not specifically django.

You would normally do:

class User(models.Model):
def __init__(self):
name = ...

but this looks not cool) That's why most of python libraries use "declarative" 
syntax to describe models:

class User(models.Model):
name = ...

And then behind the scenes they just hide that name variable somewhere and 
create another name object-variable.
I think that is frustrating for newbies and lots of other users since it's hard 
to understand difference between object-properties and class-properties)

That's one of things why python is broken, imho. But it's still better then 
everything else)

02.03.2011, 23:02, "Alex Hall" ;:

>  Hi all,
>  Still working through that tutorial. I am just curious: why are none
>  of the class variables called self.var, but rather just var? For
>  example:
>  import models
>  class Poll(models.Model):
>   question=models.CharField(max_length=200)
>
>  Should that not be
>  self.question=...
>  instead? Otherwise, saying something like:
>  poll=Poll()
>  poll.question="question?"
>  should not work; question is not told to be part of the class by way
>  of self. This may stray from django and into pure python territory, so
>  sorry if it gets off-topic. I have never seen a class that does not
>  tie its variables to itself with self or some other keyword. Come to
>  think of it, there is no __init__ method. I know that it is not
>  necessary to have one, but I figured I would have seen one to get
>  things set up.
>
>  --
>  Have a great day,
>  Alex (msg sent from GMail website)
>  mehg...@gmail.com; http://www.facebook.com/mehgcap
>
>  --
>  You received this message because you are subscribed to the Google Groups 
> "Django users" group.
>  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.
-- 
jabber: k...@ya.ru

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



logging in a user to more than one site

2011-03-03 Thread Benedict Verheyen
Hi,

i have a problem with logging in a user to more than one site.
SIte A and B are on the same subdomain.

When a user visits site B, he is redirected to site A.
Site A shows a login screen, checks the credentials with LDAP.
After a succesful login, the user is redirected back to site B.

However, when I then visit site A, the user is logged out (Anonymous)
The userdatabase is in the database of site A and site B gets the info
by using multiple databases and thus getting the info from site A.

As for some more detailed info, site B has a login view.
>From there, I redirect to site A with a return param specified as GET 
>parameter to
this same login view.
When i get there, i receive the user id, and get the user like this (in the 
backend to authenticate)

user = User.objects.using('central_users').get(pk=key)

where 'central_users' is specified in settings.py:

'central_users': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'site A',
'USER': 'xxx',
'PASSWORD': 'xxx',
'HOST': 'localhost',
'PORT': '',
}

This finally works but as i said, I then run into problems on site A, the user 
is logged out.
The user is first logged in, in site A when i check the credentials.

Would this have anything to do with the fact that the user gets logged out 
later?

Trying to log in a user to more than 1 site is more frustrating than i thought 
:)

Regards,
Benedict

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: JavaScript Parameter

2011-03-03 Thread urukay
Hi,

what script do you mean, how does it look like?

If you are using JQuery, just use JQuery's UI autocomplete to do the
same thing.

Radovan

On 3. Mar., 13:01 h., "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> Hi,
>
> I finally found a JavaScript that gives me autosuggest functionality for
> a textfield.
> Unfortunately this script uses a hard-coded array for the suggestions
> and of courese i want to use values from my database.
>
> Any idea how i could pass the javascript an array that contains all my
> values ?!
>
> Im calling the script like this in my template:  onLoad="createAutoComplete();">
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread bruno desthuilliers
On 3 mar, 15:16, kost BebiX  wrote:
> Yes, that's more a Python problem, not specifically django.
>
> You would normally do:
>
> class User(models.Model):
>     def __init__(self):
>         name = ...
>
> but this looks not cool) That's why most of python libraries use 
> "declarative" syntax to describe models:
>
> class User(models.Model):
>     name = ...


It has nothing to do with "looking cool" or anything like that. Using
models.fields as class attributes in models class statement's body
allow for the ORM to know what db fields and relations your table has
- not what instance attributes a model instance will have. Well, not
directly at least - of course the Model base case makes sure your
instance will have corresponding instance attributes (for db fields),
but note that these instance attributes are just plain python
attributes, NOT the models.fields you defined at the class level.


> And then behind the scenes they just hide that name variable somewhere and 
> create another name object-variable.

That's a very dumbed-down explanation of what happens.

> I think that is frustrating for newbies and lots of other users since it's 
> hard to understand difference between object-properties and class-properties)

s/object/instance/. Python classes are objects too. And FWIW, s/
properties/attributes/, in Python 'property' is a builtin type used
for simple computed attributes.

Also and FWIW, Django is a Python framework, so "users" are supposed
to be Python programmers.

> That's one of things why python is broken, imho.

Saying so just show your lack of understanding of Python's very
powerful object model. It might not fit your brain, but that doesn't
make it "broken" in any way.

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



problem with url

2011-03-03 Thread luca72
hello i have define this in the url:
(r'^admin/', include(admin.site.urls)),
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
(r'^mostro_prima', 'prova.test_sito.views.mostro_prima'),
(r'$', 'prova.test_sito.views.mostro_prima'),
(r'^inserisco/', 'prova.test_sito.views.inserisco'),
(r'^/registrazione/', 'prova.test_sito.views.registrazione'),
(r'^scarico/(\d+)', 'prova.test_sito.views.scarico'),
(r'^login_us/', 'prova.test_sito.views.login_us'),
(r'^registrazione/', 'prova.test_sito.views.registrazione'),
(r'^info/(\d)', 'prova.test_sito.views.info'),
(r'^chiarimenti/(\d+)', 'prova.test_sito.views.chiarimenti'),

when i go to www.mysite.net
i correctly see the page, but when i try to reach other page i get
every time the same first page, where is my mistake?

thanks

Luca

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



Re: problem with url

2011-03-03 Thread Mike Ramirez
On Thursday, March 03, 2011 08:00:45 am luca72 wrote:
> hello i have define this in the url:
> (r'^admin/', include(admin.site.urls)),
> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
> (r'^mostro_prima', 'prova.test_sito.views.mostro_prima'),
> (r'$', 'prova.test_sito.views.mostro_prima'),
> (r'^inserisco/', 'prova.test_sito.views.inserisco'),
> (r'^/registrazione/', 'prova.test_sito.views.registrazione'),
> (r'^scarico/(\d+)', 'prova.test_sito.views.scarico'),
> (r'^login_us/', 'prova.test_sito.views.login_us'),
> (r'^registrazione/', 'prova.test_sito.views.registrazione'),
> (r'^info/(\d)', 'prova.test_sito.views.info'),
> (r'^chiarimenti/(\d+)', 'prova.test_sito.views.chiarimenti'),
> 
> when i go to www.mysite.net
> i correctly see the page, but when i try to reach other page i get
> every time the same first page, where is my mistake?
> 
> thanks
> 
> Luca

This is the ordering of your urls,  see the example in the page linked[1] 
below.

I'm pretty sure admin/ acounts/login mostro_prima work as expected, it's 
everything underneath that appears broken.  That's because Django searches in 
the order and returns the first matched url pattern.

>From the points listed below the example:
/articles/2003/ would match the first pattern in the list, not the second one, 
because the patterns are tested in order, and the first one is the first test 
to 
pass. Feel free to exploit the ordering to insert special cases like this.  

Mike

[1] http://docs.djangoproject.com/en/1.2/topics/http/urls/#example

-- 
You are sick, twisted and perverted.  I like that in a person.

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



Re: problem with url

2011-03-03 Thread Tom Evans
On Thu, Mar 3, 2011 at 4:00 PM, luca72  wrote:
> hello i have define this in the url:
> (r'^admin/', include(admin.site.urls)),
>    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>    (r'^mostro_prima', 'prova.test_sito.views.mostro_prima'),
>    (r'$', 'prova.test_sito.views.mostro_prima'),
>    (r'^inserisco/', 'prova.test_sito.views.inserisco'),
>    (r'^/registrazione/', 'prova.test_sito.views.registrazione'),
>    (r'^scarico/(\d+)', 'prova.test_sito.views.scarico'),
>    (r'^login_us/', 'prova.test_sito.views.login_us'),
>    (r'^registrazione/', 'prova.test_sito.views.registrazione'),
>    (r'^info/(\d)', 'prova.test_sito.views.info'),
>    (r'^chiarimenti/(\d+)', 'prova.test_sito.views.chiarimenti'),
>
> when i go to www.mysite.net
> i correctly see the page, but when i try to reach other page i get
> every time the same first page, where is my mistake?
>
> thanks
>
> Luca
>

In addition/correction to what Mike said:

(r'$', 'prova.test_sito.views.mostro_prima'),

This regexp '$', literally means - "does this string contain the
sequence 'end of string'", which of course, all strings do, so every
request with a URL that is not matched by one of the URLs preceding
this one will be routed to this view. This is the same as Mike has
told you.

The correction is not to fiddle with the ordering of your regular
expressions, it is better to fix your regular expression so that it is
correct. I am 99.999% certain that you meant the regular expression to
match the empty string, in which case the regexp should be '^$'. With
that fixed, the ordering is irrelevant.

Cheers

Tom

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



GDAL_LIBRARY_PATH

2011-03-03 Thread Kevin
Hey All,

I'm having a hell of a time getting GeoDjango working on Windows 7,
and wondering if I could get a couple of pointers.

With the newest FWTools, where should I be pointing
GDAL_LIBRARY_PATH?

My GDAL binaries would appear to be in C:\Program Files
(x86)\FWTools2.4.7\bin.

I have that directory in my PATH environment variable, and can run
those exes off of the command line.

I have tried adding an environment variable for GDAL_LIBRARY_PATH that
points to it.

I have also tried adding an entry to my settings.py that points to it.

And lastly, have tried this directly:

>>> GDAL_LIBRARY_PATH = 'C:/Program Files (x86)/FWTools2.4.7/bin'
>>> import django.contrib.gis.gdal
>>> HAS_GDAL
False

I would use the GeoDjango windows installer, but all of the included
packages seem to be quite out of date.

Thanks for any insight anyone can provide.

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



Re: problem with url

2011-03-03 Thread luca72
i have solved using:
(r'^$', 'prova.test_sito.views.mostro_prima'),

witout the ^  , for every address he show me the mostro_prima view

Thanks

Luca

On 3 Mar, 17:24, Tom Evans  wrote:
> On Thu, Mar 3, 2011 at 4:00 PM, luca72  wrote:
> > hello i have define this in the url:
> > (r'^admin/', include(admin.site.urls)),
> >    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
> >    (r'^mostro_prima', 'prova.test_sito.views.mostro_prima'),
> >    (r'$', 'prova.test_sito.views.mostro_prima'),
> >    (r'^inserisco/', 'prova.test_sito.views.inserisco'),
> >    (r'^/registrazione/', 'prova.test_sito.views.registrazione'),
> >    (r'^scarico/(\d+)', 'prova.test_sito.views.scarico'),
> >    (r'^login_us/', 'prova.test_sito.views.login_us'),
> >    (r'^registrazione/', 'prova.test_sito.views.registrazione'),
> >    (r'^info/(\d)', 'prova.test_sito.views.info'),
> >    (r'^chiarimenti/(\d+)', 'prova.test_sito.views.chiarimenti'),
>
> > when i go towww.mysite.net
> > i correctly see the page, but when i try to reach other page i get
> > every time the same first page, where is my mistake?
>
> > thanks
>
> > Luca
>
> In addition/correction to what Mike said:
>
> (r'$', 'prova.test_sito.views.mostro_prima'),
>
> This regexp '$', literally means - "does this string contain the
> sequence 'end of string'", which of course, all strings do, so every
> request with a URL that is not matched by one of the URLs preceding
> this one will be routed to this view. This is the same as Mike has
> told you.
>
> The correction is not to fiddle with the ordering of your regular
> expressions, it is better to fix your regular expression so that it is
> correct. I am 99.999% certain that you meant the regular expression to
> match the empty string, in which case the regexp should be '^$'. With
> that fixed, the ordering is irrelevant.
>
> Cheers
>
> Tom

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



Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

2011-03-03 Thread Vladimir
Dear friends!
Karen Tracey gave me great reference:
http://www.google.com/url?sa=D&q=http://groups.google.com/group/django-users/msg/7fe07998db471693
There is reference to original work:
http://victor-k-development.blogspot.com/2010/07/unicodedecodeerror-django.html
Victor discovered a cause of this bug: python 2.7 works erroneously in
case of non-latin names in Windows register. Windows often do so for
russian users.
I was frightened to edit Windows register, so I deleted Python 2.7 and
installed Python 2.6.
This helped me.
Thank You all very much!
Could you organisers place this information to the Django site for all
russian beginners ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



What happened to django.db.models.query.CollectedObjects in 1.3?

2011-03-03 Thread Bufke
I was playing around with 1.3 beta and svn and it looks like
django.db.models.query.CollectedObjects is just gone. I couldn't find
anything about it being removed does anyone know what happened to it?
I was using it as described http://djangosnippets.org/snippets/1282/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Override AdminAuthentication form for custom auth in Django Admin

2011-03-03 Thread Nick Serra
Hey everyone, thanks for looking.

Running into a problem getting the Django Admin working with a custom
auth system. Have everything working, but I cannot get the admin to
use my custom auth app to login. I am not running a custom auth
backend, but an entirely different auth app in my project. Basically I
need to override the admin's usage of the AdminAuthentication form in
the admin forms py. I can't think of any good way to do this. Any
suggestions? Thanks!

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



Re: What happened to django.db.models.query.CollectedObjects in 1.3?

2011-03-03 Thread Tom Evans
On Thu, Mar 3, 2011 at 5:15 PM, Bufke  wrote:
> I was playing around with 1.3 beta and svn and it looks like
> django.db.models.query.CollectedObjects is just gone. I couldn't find
> anything about it being removed does anyone know what happened to it?
> I was using it as described http://djangosnippets.org/snippets/1282/
>

This is the problem when using undocumented internal parts of an API;
they change on you.

This is the change that removed it:

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

Seems like they are now using a Collector object to do the same thing,
but more efficiently.

Cheers

Tom

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



Re: oAuth 2.0

2011-03-03 Thread Mick
First are you trying to preform actions on the user's behalf on a thrid party 
site, or are you trying to authorize third parties to take an action on behalf 
of a user of your site? (are you a Client or a Server in this case?)


if you are a Client you need to request a request_token for the service you are 
authenticating with, redirect the user to an authorization url for them to 
login/authorize you, and then exchange the request token for an access_token. 
That is what the python-auth2 django example code does.

If you are a Server wanting to hand out keys to authenticate your service's 
users, there is a Server class in python-oauth2 that will be very helpful 
(especially in checking request signatures) But I dont know of any example 
django code (Someone else might).


_Mick
On Thursday, March 3, 2011 at 2:51 AM, Олег Корсак wrote: 
> Yes. But I'm stuck with first step... As I understood - first of all I need 
> to ask for request_token from my server. Done this. But what kind of token 
> and how server needs to return? 
> - Исходное сообщение -
> > In the README for python-oauth2
> > (https://github.com/simplegeo/python-oauth2) there is a good example in
> > the "Logging into Django w/ Twitter" section.
> > 
> > 
> > 
> > 
> > _Mick
> > On Wednesday, March 2, 2011 at 2:36 PM, Олег Корсак wrote: 
> > > hello. Is there any tutorial/example about oAuth 2.0 built into Django
> > > and through python-oauth2-1.2.1 ? thanks
> > 
> > -- 
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group. To post to this group, send email to
> > django-users@googlegroups.com. To unsubscribe from this group, send
> > email to django-users+unsubscr...@googlegroups.com. For more options,
> > visit this group at http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: curious about model classes

2011-03-03 Thread Lorenzo Franceschini

On 03/03/2011 04:33 PM, bruno desthuilliers wrote:

It has nothing to do with "looking cool" or anything like that. Using
models.fields as class attributes in models class statement's body
allow for the ORM to know what db fields and relations your table has
- not what instance attributes a model instance will have. Well, not
directly at least - of course the Model base case makes sure your
instance will have corresponding instance attributes (for db fields),
but note that these instance attributes are just plain python
attributes, NOT the models.fields you defined at the class level.


I have a question about this point.
In one Django application I'm writing, I would like to programatically 
add some attributes to a model instance when it's retrieved from the 
database.


I thought this would work:

class Foo(models.Model):
bar = models.CharField(max_length=10)
def __init__(self, *args, **kwargs):
super(Foo, self).__init__(self, *args, **kwargs)
self.foobar = do_something(bar)

f = Foo(bar='test')

Until then, it's ok: the model instance 'f' is created and so the 
attribute f.foobar; but when I try to save the instance to the db


f.save()

Django fails with an obscure (for me) error:
--
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/base.py", 
line 458, in save
self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/base.py", 
line 520, in save_base

manager.using(using).filter(pk=pk_val).exists())):
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/query.py", 
line 561, in filter

return self._filter_or_exclude(False, *args, **kwargs)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/query.py", 
line 579, in _filter_or_exclude

clone.query.add_q(Q(*args, **kwargs))
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/query.py", 
line 1170, in add_q

can_reuse=used_aliases, force_having=force_having)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/query.py", 
line 1105, in add_filter

connector)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/where.py", 
line 67, in add

value = obj.prepare(lookup_type, value)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/where.py", 
line 316, in prepare

return self.field.get_prep_lookup(lookup_type, value)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/fields/__init__.py", 
line 292, in get_prep_lookup

return self.get_prep_value(value)
  File 
"/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/fields/__init__.py", 
line 479, in get_prep_value

return int(value)
TypeError: int() argument must be a string or a number, not 'Foo'
---

What's wrong with this approach ?















--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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: JavaScript Parameter

2011-03-03 Thread Bill Freeman
Or if this is a static at page load array, render it in a  tag
in your template.

On Thu, Mar 3, 2011 at 9:17 AM, urukay  wrote:
> Hi,
>
> what script do you mean, how does it look like?
>
> If you are using JQuery, just use JQuery's UI autocomplete to do the
> same thing.
>
> Radovan
>
> On 3. Mar., 13:01 h., "Szabo, Patrick \(LNG-VIE\)"
>  wrote:
>> Hi,
>>
>> I finally found a JavaScript that gives me autosuggest functionality for
>> a textfield.
>> Unfortunately this script uses a hard-coded array for the suggestions
>> and of courese i want to use values from my database.
>>
>> Any idea how i could pass the javascript an array that contains all my
>> values ?!
>>
>> Im calling the script like this in my template: > onLoad="createAutoComplete();">
>>
>> Kind regards
>>
>> . . . . . . . . . . . . . . . . . . . . . . . . . .
>> Patrick Szabo
>>  XSLT Developer
>> LexisNexis
>> Marxergasse 25, 1030 Wien
>>
>> mailto:patrick.sz...@lexisnexis.at
>> Tel.: +43 (1) 534 52 - 1573
>> Fax: +43 (1) 534 52 - 146
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
>
>

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



How to group rows with same foreign key in change list table

2011-03-03 Thread hollando
I'm trying to group rows with same foreign key in admin site change
list table maybe with same color or something like a sub table which
ever is easier for implementation. Also I'm trying to do a button like
"more info" and while hit the button, the table will be expand and
show the foreign key item.
Any idea how to implement this?

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



Re: curious about model classes

2011-03-03 Thread bruno desthuilliers
On 3 mar, 19:05, Lorenzo Franceschini
 wrote:
> On 03/03/2011 04:33 PM, bruno desthuilliers wrote:
> I have a question about this point.
> In one Django application I'm writing, I would like to programatically
> add some attributes to a model instance when it's retrieved from the
> database.
>
> I thought this would work:
>
> class Foo(models.Model):
>              bar = models.CharField(max_length=10)
>              def __init__(self, *args, **kwargs):
>                  super(Foo, self).__init__(self, *args, **kwargs)

You want:

   super(Foo, self).__init__(*args, **kwargs)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Server HTTP Client

2011-03-03 Thread Julian
Hi,

Is there anything on in Python or Django that can be used as a server
side HTTP Client. Something like  HTTP Unit and jsdom from NodeJS.

I'm trying to log into some custom site and scrap the data from them.
It would be a plus if the client also support javascript.

Thanks.


Julian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: oAuth 2.0

2011-03-03 Thread Олег Корсак
actually I'm going to do both :)

So first Client (consumer) needs to do this:
consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
client = oauth.Client(consumer)

data['resp'], data['content'] = client.request(REQUEST_TOKEN_URL, 'GET')
-
And then Server needs to return token. The problem is that I can't find
how to do this in python-oauth2 way (not with Django).
Right now I have:
def request_token(request):
data = {'token': 'token123'}
return HttpResponse(simplejson.dumps(data), content_type =
'application/javascript; charset=utf8')

but this is for testing purpose only. I don't even know what token
should look like.

03.03.2011 19:56, Mick пишет:
> First are you trying to preform actions on the user's behalf on a thrid
> party site, or are you trying to authorize third parties to take an
> action on behalf of a user of your site?  (are you a Client or a Server
> in this case?)
> 
> 
> if you are a Client you need to request a request_token for the service
> you are authenticating with, redirect the user to an authorization url
> for them to login/authorize you, and then exchange the request token for
> an access_token.  That is what the python-auth2 django example code does.
> 
> If you are a Server  wanting to hand out keys to authenticate your
> service's users, there is a Server class in python-oauth2 that will be
> very helpful (especially in checking request signatures) But I dont know
> of any example django code (Someone else might).
> 
> 
> _Mick
> 
> On Thursday, March 3, 2011 at 2:51 AM, Олег Корсак wrote:
> 
>> Yes. But I'm stuck with first step... As I understood - first of all I
>> need to ask for request_token from my server. Done this. But what kind
>> of token and how server needs to return?
>> - Исходное сообщение -
>>> In the README for python-oauth2
>>> (https://github.com/simplegeo/python-oauth2) there is a good example in
>>> the "Logging into Django w/ Twitter" section.
>>>
>>>
>>>
>>>
>>> _Mick
>>> On Wednesday, March 2, 2011 at 2:36 PM, Олег Корсак wrote:
 hello. Is there any tutorial/example about oAuth 2.0 built into Django
 and through python-oauth2-1.2.1 ? thanks
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group. To post to this group, send email to
>>> django-users@googlegroups.com .
>>> To unsubscribe from this group, send
>>> email to django-users+unsubscr...@googlegroups.com
>>> . For more options,
>>> visit this group at http://groups.google.com/group/django-users?hl=en.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> 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.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> 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.



signature.asc
Description: OpenPGP digital signature


Re: Form/view for ManyToMany relationship

2011-03-03 Thread werefr0g

Hello,

Sorry if I misunderstand, but what is wrong about using a ModelForm on 
your Film bounded to the film instance?


Regards

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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: Server HTTP Client

2011-03-03 Thread Marwan Al-Sabbagh
mechanize is a very powerful library that can help you do this stuff. the
project page is at http://wwwsearch.sourceforge.net/mechanize . I've used it
in my work place and it works quite well.

cheers,
Marwan

On Thu, Mar 3, 2011 at 9:59 PM, Julian  wrote:

> Hi,
>
> Is there anything on in Python or Django that can be used as a server
> side HTTP Client. Something like  HTTP Unit and jsdom from NodeJS.
>
> I'm trying to log into some custom site and scrap the data from them.
> It would be a plus if the client also support javascript.
>
> Thanks.
>
>
> Julian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Server HTTP Client

2011-03-03 Thread Ovnicraft
On Thu, Mar 3, 2011 at 1:59 PM, Julian  wrote:

> Hi,
>
> Is there anything on in Python or Django that can be used as a server
> side HTTP Client. Something like  HTTP Unit and jsdom from NodeJS.
>
>
I recommend you use NodeJS.

Regards,


> I'm trying to log into some custom site and scrap the data from them.
> It would be a plus if the client also support javascript.
>
> Thanks.
>
>
> Julian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> 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.
>
>


-- 
Cristian Salamea
@ovnicraft

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Creating one model row from another model save method

2011-03-03 Thread werefr0g

Hello,

You should substitute 'subgallery_set' to 'subGallery_set' (different in 
case) or specify a related_name [1] .


Regards

[1] 
http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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: Server HTTP Client

2011-03-03 Thread Julian
Hmm, yeah I heard about that. I was hoping to get something in Python.  So I'm 
can stay with one technology and language. 



On Mar 3, 2011, at 3:47 PM, Marwan Al-Sabbagh wrote:

> mechanize is a very powerful library that can help you do this stuff. the 
> project page is at http://wwwsearch.sourceforge.net/mechanize . I've used it 
> in my work place and it works quite well.
> 
> cheers,
> Marwan
> 
> On Thu, Mar 3, 2011 at 9:59 PM, Julian  wrote:
> Hi,
> 
> Is there anything on in Python or Django that can be used as a server
> side HTTP Client. Something like  HTTP Unit and jsdom from NodeJS.
> 
> I'm trying to log into some custom site and scrap the data from them.
> It would be a plus if the client also support javascript.
> 
> Thanks.
> 
> 
> Julian
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Need help with this basic query (annotate vs aggregate)

2011-03-03 Thread Steven Sacks
Here is my model:

class PlaylistTag(models.Model):
playlist = models.ForeignKey(Playlist)
tag = models.CharField(max_length=128)
tag_count = models.PositiveIntegerField(default=1)


The way this model works is simple. If you add a tag to a playlist,
and the tag doesn't exist, the tag_count is 1. If you add the same tag
again to that playlist, the tag_count is incremented. If you remove
that tag, it is decremented. If it reaches 0, I remove the row
entirely.

A playlist can have multiple tags and a tag can belong to different
playlists.

What I want to do is wildcard search for a tag sorted by tag count
descending, but instead of returning duplicate playlists, I want to
sum the tag_count for each playlist that the search returns.

For example:

Playlist 1, "foo", 3
Playlist 1, "foobar", 2

A query for "foo" would return both of those rows, but I want to sum
them for that playlist so that playlist has a "score" of 5 for that
query and only return that playlist once in the querySet.

querySet = PlaylistTag.objects.select_related().filter(tag__icontains
= query).annotate(score=Sum("tag_count")).order_by("-score")

The missing part that I don't understand, is how do I only sum
tag_count for distinct playlists that are returned for that query.

In plain English, I am searching the PlaylistTag table by tag, and I
want to rank the results by which Playlist is most relevant for that
search by how many tags matched the query.

Does this make sense?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Need help with this basic query (annotate vs aggregate)

2011-03-03 Thread Steven Sacks
If it helps, this is, I believe, somewhat equivalent SQL:

SELECT
  playlist_id, tag, SUM(tag_count) score
FROM
  playlist_tag
WHERE
  tag like '%query%'
GROUP BY
  playlist_id
ORDER BY
  score DESC

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



Unable to process my form

2011-03-03 Thread Vijay
Hi All,
I am new to django.I am practicing Django using the book "The
Definitive Guide to Django" by Jacob and Adrian.I have installed
Django on Ubuntu.I tried to process HTML form as directed in that
book,then i am getting the following error.Please suggest me a
solution for this.


Environmen:

Request Method: GET
Request URL: http://127.0.0.1:8000/search-form/
Django Version: 1.2.4
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'mysite.books']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
 100. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/prvr/Desktop/djcode/mysite/../mysite/books/views.py" in
search_form
 4. return render_to_response('/home/prvr/Desktop/djcode/mysite/
books/search_form.html')
File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py" in render_to_response
 20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py" in render_to_string
 181. t = get_template(template_name)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Need help with this basic query (annotate vs aggregate)

2011-03-03 Thread Steven Sacks
Also, I need to get back Playlist records (hence the
select_releated()).

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



Re: Unable to process my form

2011-03-03 Thread Silvio
You don't want to pass an absolute path to render_to_response. You
want to pass a relative path. Right now you're passing '/home/prvr/
Desktop/djcode/mysite/books/search_form.html'. You want something
along the lines of "books/search_form.html".

Then in your settings.py file, be sure to add  '/home/prvr/Desktop/
djcode/mysite/' as one of the TEMPLATE_DIRS entries.

Hope that helps,

Silvio

On Mar 3, 8:00 pm, Vijay  wrote:
> Hi All,
>         I am new to django.I am practicing Django using the book "The
> Definitive Guide to Django" by Jacob and Adrian.I have installed
> Django on Ubuntu.I tried to process HTML form as directed in that
> book,then i am getting the following error.Please suggest me a
> solution for this.
>
> Environmen:
>
> Request Method: GET
> Request URL:http://127.0.0.1:8000/search-form/
> Django Version: 1.2.4
> Python Version: 2.6.4
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'mysite.books']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
> Template Loader Error:
> Django tried loading these templates, in this order:
> Using loader django.template.loaders.filesystem.Loader:
> Using loader django.template.loaders.app_directories.Loader:
>
> Traceback:
> File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> base.py" in get_response
>  100.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File "/home/prvr/Desktop/djcode/mysite/../mysite/books/views.py" in
> search_form
>  4.     return render_to_response('/home/prvr/Desktop/djcode/mysite/
> books/search_form.html')
> File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
> __init__.py" in render_to_response
>  20.     return HttpResponse(loader.render_to_string(*args,
> **kwargs), **httpresponse_kwargs)
> File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py" in render_to_string
>  181.         t = get_template(template_name)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: Form/view for ManyToMany relationship

2011-03-03 Thread kgardenia42
On Thu, Mar 3, 2011 at 11:50 AM, werefr0g  wrote:
> Hello,
>
> Sorry if I misunderstand, but what is wrong about using a ModelForm on your
> Film bounded to the film instance?

When I tried that I kept running into this error:
  "Cannot set values on a ManyToManyField which specifies an
intermediary model.  Use foo.FilmRole's Manager instead."

... which led me down a different path but perhaps I should have
persevered more.

I have googled this error extensively and spent some time digging into
Django internals to figure out what is happening.  Basically I can see
that if Django didn't auto-generate the relationship manager class
then it will throw this error.

Conceptually I totally get why that is (it has no way of knowing what
values to assign to the extra fields).  What I don't get is how I'm
supposed to get around it.  Lets say I wanted to put some code
somewhere to munge the missing fields to some default value.  Where
would I put that code?

I can't relate to the error message at all.  I read about manager
classes and how I can override query sets and so on.  Sure that
totally makes sense.  But how does that help me here?How can I use
the manager for FilmRole?  Do I need to override some method in my
manager?  Which method?   An example would be really useful here.

Thanks.

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



Re: Django Donations App

2011-03-03 Thread Venkatraman S
On Sat, Feb 26, 2011 at 5:20 AM, Francisco Ceruti <
francisco.cer...@gmail.com> wrote:

> A few months ago I successfully used this app
> https://github.com/johnboxall/django-paypal
>
> I hope this can help you :)
>
>
@Francisco : can you elaborate or probably write a HOWTO on this app? I
tried in vain, but looks like
django-paypal (either johnboxall or cramer's) was extremely tough to
configure. For eg.
I was not able to get a list of all items and their respective prices in the
final receipt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: db_index=True doesn't create index

2011-03-03 Thread Dario Bertini
On Mar 2, 12:15 am, Łukasz Rekucki  wrote:
> Seehttp://code.djangoproject.com/ticket/14651
>
> Also, from PostgreSQL's docs:
>
> One should, however, be aware that there's no need to manually create
> indexes on unique columns; doing so would just duplicate the
> automatically-created index.
>
> So there is just no need, to create the index - it's already there.
>


Oh, ok...

I wonder if that also applies to sqlite

Thank you for the answer

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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 1.2 + Google app engine + templatetags

2011-03-03 Thread Niklasro
Hi I run django 1.2 with GAE and I'm trying to get templatetags
working and I keep getting the
following error: 'rss' is not a valid tag library: Could you tell
what's up with this? The django snippet I tried yo add is
http://djangosnippets.org/snippets/311/ and I added the feedparser
dependency. And in template I use it like it says in the snippet. Can
you recommend a way to enable this tag library? Also enabling
http://djangosnippets.org/snippets/852 would be very niceThanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



ANN: Django 1.3 release candidate available

2011-03-03 Thread James Bennett
Tonight we're proud to announce the first release candidate for Django
1.3; if all goes well, the final release will happen in about a week.

Details for the release candidate are available on the official Django weblog:

http://www.djangoproject.com/weblog/2011/mar/03/13-rc/


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

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



adding model_dict['admin'] = model_admin is good idea?

2011-03-03 Thread hdknr
Hello,

I'm customizing admin UI to add extra menus but I found it is not
easy. So thinking of adding "admin" to model_dict in index() and
app_index() ( source:django/trunk/django/contrib/admin/sites.py ) to
refere to ModeAdmin objects in templates.
Is there any pitfall in the security point of view ?

--
hideki nara

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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: ANN: Django 1.3 release candidate available

2011-03-03 Thread sebastien piquemal
Great !



However, I don't know if it is me, but I just installed it, tried to
start my development server, and I got :

  File "manage.py", line 14, in 
execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager
utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name,
name))
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
importlib.py", line 35, in import_module
__import__(name)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/
staticfiles/management/commands/runserver.py", line 4, in 
from django.core.management.commands.runserver import
BaseRunserverCommand
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/runserver.py", line 8, in 
from django.core.handlers.wsgi import WSGIHandler
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
wsgi.py", line 11, in 
from django.core import signals
  File "/usr/local/lib/python2.6/dist-packages/django/core/
signals.py", line 1, in 
from django.dispatch import Signal
  File "/usr/local/lib/python2.6/dist-packages/django/dispatch/
__init__.py", line 9, in 
from django.dispatch.dispatcher import Signal, receiver
ImportError: cannot import name receiver

Same thing goes if I start a blank project and run : `python manage.py
runserver`. Any idea ???

Sébastien


On Mar 4, 8:00 am, James Bennett  wrote:
> Tonight we're proud to announce the first release candidate for Django
> 1.3; if all goes well, the final release will happen in about a week.
>
> Details for the release candidate are available on the official Django weblog:
>
> http://www.djangoproject.com/weblog/2011/mar/03/13-rc/
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: ANN: Django 1.3 release candidate available

2011-03-03 Thread sebastien piquemal
Oh ... actually, I just deleted the django folder from `dist-packages`
and ran again `setup.py`, and now it works.

On Mar 4, 9:18 am, sebastien piquemal  wrote:
> Great !
>
> 
>
> However, I don't know if it is me, but I just installed it, tried to
> start my development server, and I got :
>
>   File "manage.py", line 14, in 
>     execute_manager(settings)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 438, in execute_manager
>     utility.execute()
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 261, in fetch_command
>     klass = load_command_class(app_name, subcommand)
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 67, in load_command_class
>     module = import_module('%s.management.commands.%s' % (app_name,
> name))
>   File "/usr/local/lib/python2.6/dist-packages/django/utils/
> importlib.py", line 35, in import_module
>     __import__(name)
>   File "/usr/local/lib/python2.6/dist-packages/django/contrib/
> staticfiles/management/commands/runserver.py", line 4, in 
>     from django.core.management.commands.runserver import
> BaseRunserverCommand
>   File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> commands/runserver.py", line 8, in 
>     from django.core.handlers.wsgi import WSGIHandler
>   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> wsgi.py", line 11, in 
>     from django.core import signals
>   File "/usr/local/lib/python2.6/dist-packages/django/core/
> signals.py", line 1, in 
>     from django.dispatch import Signal
>   File "/usr/local/lib/python2.6/dist-packages/django/dispatch/
> __init__.py", line 9, in 
>     from django.dispatch.dispatcher import Signal, receiver
> ImportError: cannot import name receiver
>
> Same thing goes if I start a blank project and run : `python manage.py
> runserver`. Any idea ???
>
> Sébastien
>
> On Mar 4, 8:00 am, James Bennett  wrote:
>
> > Tonight we're proud to announce the first release candidate for Django
> > 1.3; if all goes well, the final release will happen in about a week.
>
> > Details for the release candidate are available on the official Django 
> > weblog:
>
> >http://www.djangoproject.com/weblog/2011/mar/03/13-rc/
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."

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