Re: How to share a session with a php application.

2010-06-07 Thread nameless
Hi,

In your opinion what is the best way to share userid with the PHP
application ?


---

On Jun 7, 7:59 am, Dmitry Dulepov <dmitry.dule...@gmail.com> wrote:
> Hi!
>
> nameless wrote:
> > Someone has telled me that I could share the user id ( from Django and
> > PHP )
> >  also throught a cookie.
> > In your opinion what is the best way ?
>
> What would prevent me from forging a cookie with somebody else's user id
> and impersonating another user? It is a major security issue.
>
> --
> Dmitry Dulepov
> Twitter:http://twitter.com/dmitryd/
> Web:http://dmitry-dulepov.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How to share a session with a php application.

2010-06-06 Thread nameless
hep :D

On Jun 5, 7:41 pm, nameless <xsatelli...@gmail.com> wrote:
> I want to add cometchat ( written in PHP ) in my djangoproject and I
> need to
> edit this function to get it work ( a function that return the userid
> of the user logged in ):
>
> function getUserID() {
>
>        // I could use SESSION or other to get the user id fo the user
> logged in:
>
>         if (!empty($_SESSION['userid'])) { $userid = $_SESSION['userid'];     
>   }
>
>         return $userid;
>
> }
>
> How could I do that ?
>
> --
> On Jun 5, 7:28 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
>
> > Not directly.
>
> > The session cookie stores the session id (session key). The session id
> > references data stored for the session in the django session backend.
> > The user for that session is contained in that data. So it really
> > depends on what the session backend is. So I'll assume it's the
> > default which is the database backend which keeps this data in the
> > django_session table, which has a column session_data which holds an
> > encoded (pickled) python dict with the session data, which I'm 99.99%
> > sure you can't decode directly from PHP, because it's a serialize
> > Python object. So if you can't access it directly from PHP you need to
> > open a service of some sort on your django application or anything
> > that's written in python that would give this data to the PHP
> > application, this service should be only accessed from the PHP app on
> > the serverside for good security. So it requires punching holes for no
> > special reason. Or is there something very special about this PHP
> > script that you can't do with 10-200 times less code in your django
> > application?
>
> > On Sat, Jun 5, 2010 at 5:18 PM, nameless <xsatelli...@gmail.com> wrote:
>
> > > Someone has telled me that I could share the user id ( from Django and
> > > PHP )
> > >  also throught a cookie.
> > > In your opinion what is the best way ?
>
> > > Thanks ^_^
>
> > > -
>
> > > On Jun 5, 4:01 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> > >> set
>
> > >> SESSION_COOKIE_DOMAIN=".mychatapp.com"
>
> > >> this will make the django cookie valid both forwww.mychat.comand
> > >> chat.mychat.com
>
> > >> On Sat, Jun 5, 2010 at 2:34 PM, nameless <xsatelli...@gmail.com> wrote:
> > >> > If the chat is in a subdomain ?
>
> > >> > 
>
> > >> > On Jun 5, 2:05 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> > >> >> It's possible if both of your applications are under the same domain.
> > >> >> see the SESSION_COOKIE_* settings variables
>
> > >> >>http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age
>
> > >> >> You can then find the current user by the sessionid from the django_* 
> > >> >> tables.
>
> > >> >> On Sat, Jun 5, 2010 at 1:40 PM, nameless <xsatelli...@gmail.com> 
> > >> >> wrote:
>
> > >> >> > I have a django blog project and a chat in PHP.
>
> > >> >> > I need to share the id of the user logged in django
> > >> >> > ( request.user.id ) with the chat in PHP.
>
> > >> >> > Is this possible ?
>
> > >> >> > --
> > >> >> > You received this message because you are subscribed to the Google 
> > >> >> > Groups "Django users" group.
> > >> >> > To post to this group, send email to django-us...@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-us...@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-us...@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-us...@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: How to share a session with a php application.

2010-06-05 Thread nameless
I want to add cometchat ( written in PHP ) in my djangoproject and I
need to
edit this function to get it work ( a function that return the userid
of the user logged in ):


function getUserID() {



   // I could use SESSION or other to get the user id fo the user
logged in:

if (!empty($_SESSION['userid'])) { $userid = $_SESSION['userid'];   
}


return $userid;

}


How could I do that ?

--
On Jun 5, 7:28 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> Not directly.
>
> The session cookie stores the session id (session key). The session id
> references data stored for the session in the django session backend.
> The user for that session is contained in that data. So it really
> depends on what the session backend is. So I'll assume it's the
> default which is the database backend which keeps this data in the
> django_session table, which has a column session_data which holds an
> encoded (pickled) python dict with the session data, which I'm 99.99%
> sure you can't decode directly from PHP, because it's a serialize
> Python object. So if you can't access it directly from PHP you need to
> open a service of some sort on your django application or anything
> that's written in python that would give this data to the PHP
> application, this service should be only accessed from the PHP app on
> the serverside for good security. So it requires punching holes for no
> special reason. Or is there something very special about this PHP
> script that you can't do with 10-200 times less code in your django
> application?
>
> On Sat, Jun 5, 2010 at 5:18 PM, nameless <xsatelli...@gmail.com> wrote:
>
> > Someone has telled me that I could share the user id ( from Django and
> > PHP )
> >  also throught a cookie.
> > In your opinion what is the best way ?
>
> > Thanks ^_^
>
> > -
>
> > On Jun 5, 4:01 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> >> set
>
> >> SESSION_COOKIE_DOMAIN=".mychatapp.com"
>
> >> this will make the django cookie valid both forwww.mychat.comand
> >> chat.mychat.com
>
> >> On Sat, Jun 5, 2010 at 2:34 PM, nameless <xsatelli...@gmail.com> wrote:
> >> > If the chat is in a subdomain ?
>
> >> > 
>
> >> > On Jun 5, 2:05 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> >> >> It's possible if both of your applications are under the same domain.
> >> >> see the SESSION_COOKIE_* settings variables
>
> >> >>http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age
>
> >> >> You can then find the current user by the sessionid from the django_* 
> >> >> tables.
>
> >> >> On Sat, Jun 5, 2010 at 1:40 PM, nameless <xsatelli...@gmail.com> wrote:
>
> >> >> > I have a django blog project and a chat in PHP.
>
> >> >> > I need to share the id of the user logged in django
> >> >> > ( request.user.id ) with the chat in PHP.
>
> >> >> > Is this possible ?
>
> >> >> > --
> >> >> > You received this message because you are subscribed to the Google 
> >> >> > Groups "Django users" group.
> >> >> > To post to this group, send email to django-us...@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-us...@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-us...@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-us...@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: How to share a session with a php application.

2010-06-05 Thread nameless

Someone has telled me that I could share the user id ( from Django and
PHP )
 also throught a cookie.
In your opinion what is the best way ?

Thanks ^_^

-

On Jun 5, 4:01 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> set
>
> SESSION_COOKIE_DOMAIN=".mychatapp.com"
>
> this will make the django cookie valid both forwww.mychat.comand
> chat.mychat.com
>
> On Sat, Jun 5, 2010 at 2:34 PM, nameless <xsatelli...@gmail.com> wrote:
> > If the chat is in a subdomain ?
>
> > 
>
> > On Jun 5, 2:05 pm, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> >> It's possible if both of your applications are under the same domain.
> >> see the SESSION_COOKIE_* settings variables
>
> >>http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-age
>
> >> You can then find the current user by the sessionid from the django_* 
> >> tables.
>
> >> On Sat, Jun 5, 2010 at 1:40 PM, nameless <xsatelli...@gmail.com> wrote:
>
> >> > I have a django blog project and a chat in PHP.
>
> >> > I need to share the id of the user logged in django
> >> > ( request.user.id ) with the chat in PHP.
>
> >> > Is this possible ?
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group.
> >> > To post to this group, send email to django-us...@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-us...@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-us...@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.



IntegrityError with BooleanField and Postgresql

2010-05-27 Thread nameless


I have this simple Blog model:

class Blog(models.Model):

title = models.CharField(_('title'), max_length=60, blank=True,
null=True)
body = models.TextField(_('body'))
user = models.ForeignKey(User)
is_public = models.BooleanField(_('is public'), default = True)

When I insert a blog in admin interface, I get this error:

IntegrityError at /admin/blogs/blog/add/

null value in column "is_public" violates not-null constraint

Why ???

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



Re: Post and Comment with the same Model.

2010-05-25 Thread nameless
mmm so I could use Post model with a foreign key to blog and a Comment
model with a generic foreign key ( because I could comment post,
images, videos, ecc ). Is this a wrong ? What is the better solution
in your opinion ? Thanks ^_^


-

On 25 Mag, 13:32, Tom Evans <tevans...@googlemail.com> wrote:
> On Tue, May 25, 2010 at 12:20 PM, nameless <xsatelli...@gmail.com> wrote:
> > Generic field because on my project you can post and comment in Blogs,
> > Gallery pages, Foto pages, video pages, ecc.
> > So I want to use my Post_comment models for post and comment
> > anythings.
> > Is this a wrong solution ?
> > Are there problems with the performances ?
>
> > Thanks ;)
>
> Well, GFKs aren't cheap (or rather, can be expensive).
>
> It depends whether you think that galleries/photos/videos have
> posts/comments (m2m from gallery/photo to post/comment), or that
> posts/comments are associated with any object (GFK).
>
> The GFK allows you to easily find the object associated with a
> post/comment. The m2m approach allows you to easily find the comments
> associated with a particular object.
>
> 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-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Post and Comment with the same Model.

2010-05-25 Thread nameless
Generic field because on my project you can post and comment in Blogs,
Gallery pages, Foto pages, video pages, ecc.
So I want to use my Post_comment models for post and comment
anythings.
Is this a wrong solution ?
Are there problems with the performances ?

Thanks ;)


On 25 Mag, 12:19, Scott Gould <zinck...@gmail.com> wrote:
> Presumably you want the same object to be able to be a comment on
> someone else's post as well as a post in it's own right, that others
> could comment on? Looks straightforward enough, though I can't see why
> you'd need the generic fields in the model.
>
> Regards
> Scott
>
> On May 25, 5:54 am, nameless <xsatelli...@gmail.com> wrote:
>
>
>
>
>
> > I have created a simple project where everyone can create one or more
> > Blog. I want to use this models for Post and for Comment:
>
> > class Post_comment(models.Model):
> >     content_type = models.ForeignKey(ContentType)
> >     object_id = models.PositiveIntegerField(_('object ID'))
> >     content_object = generic.GenericForeignKey()
>
> >     # Hierarchy Field
> >     parent = models.ForeignKey('self', null=True, blank=True,
> > default=None, related_name='children')
>
> >     # User Field
> >     user = models.ForeignKey(User)
>
> >     # Date Fields
> >     date_submitted = models.DateTimeField(_('date/time submitted'),
> > default = datetime.now)
> >     date_modified = models.DateTimeField(_('date/time modified'),
> > default = datetime.now)
>
> >     title = models.CharField(_('title'), max_length=60, blank=True,
> > null=True)
> >     post_comment = models.TextField(_('post_comment'))
>
> > if it is a comment the parent is not null. So in most case the text
> > field will contain a little bit of text. Can I use this model for both
> > Post and Comment ? Is it a good solution ?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Post and Comment with the same Model.

2010-05-25 Thread nameless


I have created a simple project where everyone can create one or more
Blog. I want to use this models for Post and for Comment:

class Post_comment(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField(_('object ID'))
content_object = generic.GenericForeignKey()

# Hierarchy Field
parent = models.ForeignKey('self', null=True, blank=True,
default=None, related_name='children')

# User Field
user = models.ForeignKey(User)

# Date Fields
date_submitted = models.DateTimeField(_('date/time submitted'),
default = datetime.now)
date_modified = models.DateTimeField(_('date/time modified'),
default = datetime.now)

title = models.CharField(_('title'), max_length=60, blank=True,
null=True)
post_comment = models.TextField(_('post_comment'))

if it is a comment the parent is not null. So in most case the text
field will contain a little bit of text. Can I use this model for both
Post and Comment ? Is it a good solution ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How to save links in the TextField

2010-05-24 Thread nameless
mmm I could use also javascript or css and render the links on client
side ?



-

On 24 Mag, 14:00, Marcus Carlsson <carlsson.mar...@gmail.com> wrote:
> A better approach would be just saving the link (not using html markup)
> and then apply a filter to those links. This result could later on be
> cached if performance is an issue. If you later on modify the saved
> links, just remember to empty the cache.
> On 24 May 04:55, nameless wrote:
>
>
>
>
>
> > mmm 2 textfields for the same information ?
> > Is this a good approach ?
>
> > --
>
> > On 22 Mag, 20:11, Rolando Espinoza La Fuente <dark...@gmail.com>
> > wrote:
> > > On Fri, May 21, 2010 at 6:12 PM, nameless <xsatelli...@gmail.com> wrote:
>
> > > > I have a simple Blog model with a TextField. What is the best way to
> > > > save links in the TextField ?
>
> > > > 1) Saving link in the database in this form:http://www.example.com
> > > > and then using some filter in the template to trasform it in form:
>
> > > > http://www.example.com>http://www.example.com > > > a>
>
> > > > 2) Saving link in the database directly in this form:
>
> > > > http://www.example.com>http://www.example.com > > > a>
>
> > > I think you are talking about pre-render vs post-render of a text. In
> > > both case you use
> > > a filter or processor to transform the raw text into html (or other 
> > > format).
>
> > > afaik, most efficient is pre-render. You just create an extra field
> > > non-editable by the user,
> > > e.g.
>
> > > class Foo(...)
> > >     text = TextField()
> > >     text_html = TextField()
>
> > > And using pre-save signal for Foo model you can process the raw text
> > > and store it in text_html field.
> > > When you display the rendered text you just show text_html field in
> > > your templates.
>
> > > Hope it helps.
>
> > > ~Rolando
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@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-us...@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-us...@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-us...@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: How to save links in the TextField

2010-05-24 Thread nameless
mmm 2 textfields for the same information ?
Is this a good approach ?


--

On 22 Mag, 20:11, Rolando Espinoza La Fuente <dark...@gmail.com>
wrote:
> On Fri, May 21, 2010 at 6:12 PM, nameless <xsatelli...@gmail.com> wrote:
>
> > I have a simple Blog model with a TextField. What is the best way to
> > save links in the TextField ?
>
> > 1) Saving link in the database in this form:http://www.example.com
> > and then using some filter in the template to trasform it in form:
>
> > http://www.example.com>http://www.example.com > a>
>
> > 2) Saving link in the database directly in this form:
>
> > http://www.example.com>http://www.example.com > a>
>
> I think you are talking about pre-render vs post-render of a text. In
> both case you use
> a filter or processor to transform the raw text into html (or other format).
>
> afaik, most efficient is pre-render. You just create an extra field
> non-editable by the user,
> e.g.
>
> class Foo(...)
>     text = TextField()
>     text_html = TextField()
>
> And using pre-save signal for Foo model you can process the raw text
> and store it in text_html field.
> When you display the rendered text you just show text_html field in
> your templates.
>
> Hope it helps.
>
> ~Rolando
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: How to save links in the TextField

2010-05-22 Thread nameless
help please :D




On 22 Mag, 00:12, nameless <xsatelli...@gmail.com> wrote:
> I have a simple Blog model with a TextField. What is the best way to
> save links in the TextField ?
>
> 1) Saving link in the database in this form:http://www.example.com
> and then using some filter in the template to trasform it in form:
>
> http://www.example.com>http://www.example.com a>
>
> 2) Saving link in the database directly in this form:
>
> http://www.example.com>http://www.example.com a>
>
> 3) other solutions
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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 save links in the TextField

2010-05-21 Thread nameless


I have a simple Blog model with a TextField. What is the best way to
save links in the TextField ?

1) Saving link in the database in this form: http://www.example.com
and then using some filter in the template to trasform it in form:

http://www.example.com>http://www.example.com

2) Saving link in the database directly in this form:

http://www.example.com>http://www.example.com

3) other solutions

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 translations doesn't work !!!

2010-05-09 Thread nameless


I have:

* created translation strings in the template and in the
application view.
* run this command: django-admin.py makemessages -l it and the
file it/LC_MESSAGES/django.po has been created
* translated strings in the django.po file.
* run this command: django-admin.py compilemessages and I receive:
processing file django.po in /home/jobber/Desktop/library/books/locale/
it/LC_MESSAGES
* set this in settings.py:

LANGUAGE_CODE = 'it'

TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth",

"django.core.context_processors.debug",

"django.core.context_processors.i18n",

"django.core.context_processors.media", )

USE_I18N = True

MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware',

'django.middleware.locale.LocaleMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

)

but translation doesn't work !! I always see english text. Why ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 and Tornado web server

2010-03-28 Thread nameless
Hi at all,
I need to create a high performance comet chat for my college project.
I have found Tornado that is a non-blocking webserver used by
FriendFeed for real-time features:
http://www.tornadoweb.org/

Maybe this is a stupid question but I am very newbie and I want to
know how to use Tornado as webserver and Django as framework. I don' t
know how to get started.

Could anyone help me please ???


Thanks :D

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How execute erlang code ?

2010-03-12 Thread nameless
The reason is that every tweet is sent and received in real time like
a web chat ( using ajax and long polling on client side ).
This is because I have chosen Erlang+Yaws+Mnesia.
Is it a wrong approach ?

thanks.


On 12 Mar, 15:20, Dylan Evans <dy...@contentfree.info> wrote:
> That's difficult to say without specifics, but you should be able to access
> your django database from erlang and reference the user table, or any other
> required data. Likewise django/python can read any sql database tables used
> with your erlang code, but probably not mnesia.
> You could also implement RPC style calls between the servers using XMLRPC or
> something simpler.
> Is there a reason you want to use two different systems?
>
>
>
>
>
> On Fri, Mar 12, 2010 at 7:41 PM, nameless <xsatelli...@gmail.com> wrote:
> > you right Dylan... maybe is better put erlang code on another
> > webserver.
> > If I use iframe How could I share users information ( on django
> > table ) with erlang ?
> > ie if I send a tweet, and that tweet is stored on erlang webserver
> > ( Mnesia ) then I have to connect that tweet with a certain user.
>
> > excuse me this is very newbie question but I never used 2 webserver
> > with 2 program languages :-\.
>
> > -
> > On 12 Mar, 07:29, Dylan Evans <dy...@contentfree.info> wrote:
> > > I would suggest running your erlang on another webserver and either using
> > an
> > > iframe or use django as a proxy (connect to erlang in your django view).
>
> > > On Fri, Mar 12, 2010 at 1:02 PM, nameless <xsatelli...@gmail.com> wrote:
> > > > Hi at all.
> > > > I need to create a blogging system with Django+Apache+Postgresql and a
> > > > twitter-like app with Erlang+Yaws+Mnesia.
>
> > > > How can I execute erlang code through django views ?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google
> > > >  groups.com>
> > <django-users%2bunsubscr...@google groups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > "The UNIX system has a command, nice ... in order to be nice to the other
> > > users. Nobody ever uses it." - Andrew S. Tanenbaum
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google 
> > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> "The UNIX system has a command, nice ... in order to be nice to the other
> users. Nobody ever uses it." - Andrew S. Tanenbaum

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: How execute erlang code ?

2010-03-12 Thread nameless
you right Dylan... maybe is better put erlang code on another
webserver.
If I use iframe How could I share users information ( on django
table ) with erlang ?
ie if I send a tweet, and that tweet is stored on erlang webserver
( Mnesia ) then I have to connect that tweet with a certain user.


excuse me this is very newbie question but I never used 2 webserver
with 2 program languages :-\.


-
On 12 Mar, 07:29, Dylan Evans <dy...@contentfree.info> wrote:
> I would suggest running your erlang on another webserver and either using an
> iframe or use django as a proxy (connect to erlang in your django view).
>
>
>
>
>
> On Fri, Mar 12, 2010 at 1:02 PM, nameless <xsatelli...@gmail.com> wrote:
> > Hi at all.
> > I need to create a blogging system with Django+Apache+Postgresql and a
> > twitter-like app with Erlang+Yaws+Mnesia.
>
> > How can I execute erlang code through django views ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google 
> > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> "The UNIX system has a command, nice ... in order to be nice to the other
> users. Nobody ever uses it." - Andrew S. Tanenbaum

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 execute erlang code ?

2010-03-11 Thread nameless
Hi at all.
I need to create a blogging system with Django+Apache+Postgresql and a
twitter-like app with Erlang+Yaws+Mnesia.

How can I execute erlang code through django views ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Serving static files from subdomain.

2010-01-17 Thread nameless
Thank you for tips.
Now I want that when an user upload an image ( through forms ), then
it will be saved in media.example.com.
This is the point that I don't understand :-\



---

On Jan 18, 1:08 am, Malcolm Box <malcolm@gmail.com> wrote:
> On Sat, Jan 16, 2010 at 3:20 PM, nameless <xsatelli...@gmail.com> wrote:
> > I have a site developed with django atwww.example.com
>
> > I want that django insert/serve static files ( images, css, js, ect )
> > in/from media.example.com.
>
> Are these files that Django is managing (e.g. via an upload), or just part
> of the output HTML?
>
> If just part of the output HTML, all you need to do is go through your
> templates and change the paths in the URLs to point to
> media.example.comrather thanwww.example.com.  For bonus points, change them 
> to use {{ MEDIA_URL
>
> }}/path/to/image and pass MEDIA_URL into your template functions.
> > I have edited settings.py:
>
> > MEDIA_ROOT = 'http://media.miosito.it'
>
> > MEDIA_URL =  'http://media.miosito.it'
>
> > ADMIN_MEDIA_PREFIX =  'http://media.miosito.it'
>
> MEDIA_ROOT needs to be a directory path, not a URL - it's where Django will
> store uploaded files for any ImageField members.
>
> > And now ? What do I do ?
>
> That depends :)
>
> Malcolm
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Serving static files from subdomain.

2010-01-16 Thread nameless
I have a site developed with django at www.example.com

I want that django insert/serve static files ( images, css, js, ect )
in/from media.example.com.

I have edited settings.py:

MEDIA_ROOT = 'http://media.miosito.it'

MEDIA_URL =  'http://media.miosito.it'

ADMIN_MEDIA_PREFIX =  'http://media.miosito.it'


And now ? What do I do ?
.

I am using Apache but I could switch to lightpd or ngix ( if there is
a valid reason ).


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-us...@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: Insert AUTOMATICALLY random string in username field

2010-01-14 Thread nameless
Sequences are best solution for me but I don't know how to implement
its in django+mysql.
I tought also to use id as username but I don't know how do this :-\

Could you explain me how do pleaseee ?
Thank you


---
On Jan 14, 4:16 pm, Shawn Milochik  wrote:
> There are a bunch of ways you can do it. As a previous poster said, you can 
> take 10 digits of the current timestamp. However, be wary of daylight saving 
> time changes (if you have them on your server), and the possibility of any 
> conflict if you change servers, have a backup server, or ever expand to 
> multiple servers for your application.
>
> A possibility, if you're open to alphanumeric strings, is a uuid, 
> specifically uuid4 or uuid1. Check out the documentation to see if they'd 
> work for you. If you don't care to necessarily limit it to 10 characters, and 
> you don't mind alpha-numeric characters, then just use a uuid4 and you're 
> done.http://docs.python.org/library/uuid.html
>
> Yet another possibility is to use the capability of your database to create 
> sequences. If you're using Postgres, it has a SEQUENCE which you can create, 
> and always ask it for the next one. You can start a sequence at any number 
> you like, in order to get the size you want. We do something similar for 
> generating customer numbers. We have a sequence, and we use it appended to a 
> static set of digits for the particular program the customer is in. So, for 
> example, all customers in program X would have a customer number of 10 digits 
> starting with '1001' and ending with an incremental number. There are ways to 
> do this with other databases. Worst-case you can create a table with an 
> auto-increment key and just use its primary key for your next digit.
>
> One more, but not last nor least, is to have your model generate the string 
> you want by one of the means above, or something completely different, then 
> override the save() of your model to check to ensure that this key doesn't 
> exist already. This is less than ideal, but maybe there's a case to be made 
> for it. Just throwing it in as an option.
>
> Shawn
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Insert AUTOMATICALLY random string in username field

2010-01-14 Thread nameless


I want username field is automatically filled with this value:

username = str(n);

where n is a number of 10 digits ( autoincremented or random ).

.

I tried to add this in save method:

username = str(random.randint(10,99))

but there is a collision problem when n is the same for 2 users
( although rare initially ).

.

How do I do this ?

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-us...@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: Only Email + Password ( without username )

2010-01-14 Thread nameless
I want to use "id" as identifier for each user. So every user will
have an url like this:

http://www.example.com/827362

I don't want username for my project.
So, if I can't delete it, I think to insert email in username field
and I don't want another identifier in username field as random
strings :P
In this case I don't have to create a custom backend.
Is a good idea in your opinion ?


-

On Jan 14, 11:12 am, Alexander Dutton <d...@alexdutton.co.uk> wrote:
> On 14/01/10 09:51, nameless wrote:> I am asking whether is a good solution to 
> having 2 fields with the
> > same value ( username and email ) because both are required.
> > Or is there another solution ?
>
> This depends on whether you don't want distinct usernames hanging
> around, or you simply want people to be able to log in using their
> e-mail address.
>
> My inclination in the latter case would be to automatically generate
> usernames as random strings, but not expose them. You can then create a
> custom authentication backend[0] which uses the email address in place
> of the username.
>
> Usernames are good things to have around to refer to people, as e-mail
> addresses can change and usernames generally don't. If user details are
> to be exposed in some way (e.g.  by activity feeds or to other users)
> you want some sort of immutable identifier for each user.
>
> Again, the approach you take depends on what you're trying to do and who
> your audience is.
>
> Alex
>
> [0]http://docs.djangoproject.com/en/dev/ref/authbackends/
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Only Email + Password ( without username )

2010-01-14 Thread nameless

I am asking whether is a good solution to having 2 fields with the
same value ( username and email ) because both are required.
Or is there another solution ?
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Only Email + Password ( without username )

2010-01-14 Thread nameless


I want a Registration Form with only email + password. I am thinking
to insert automatically email in username field. So, for eash user, I
will have this:

username: exam...@example.com

password: mypassword

email: exam...@example.com

Of course email + password will be used in login process.

Is it a good solution ? Or is there a more sofisticated solution ?

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-us...@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: Table with 4 Milions of rows

2010-01-12 Thread nameless
The table is queried from ajax using an autocomplete field with this
query in the views.py:

books.objects.filter(book_title__istartswith=request.GET['q'])[:100]




---

On Jan 12, 8:47 pm, Chris Czub <chris.c...@gmail.com> wrote:
> It really depends on how you're selecting the data from the database. If
> you're doing something that necessitates a full table scan(like in-DB ORDER
> BY) it will slow you down considerably. If you're selecting one row from the
> database by an indexed column, then the performance will be very fast and
> there's no need to prematurely optimize.
>
> On Tue, Jan 12, 2010 at 2:25 PM, nameless <xsatelli...@gmail.com> wrote:
> > My table with 4 milions of rows is queried often by ajax.
> > So I think a performance problems ( I am using also index ).
> > Ok now take a look at the contenttypes :)
>
> > 
>
> > On Jan 12, 8:15 pm, Tim <timster...@gmail.com> wrote:
> > > As far as needing to split up the table into other tables, I'm not
> > > sure. Whats wrong with having 4 million records in one table?
>
> > > But if you're going to do it, take a look at the contenttypes
> > > framework and generic relations. It basically does what you're
> > > describing:
>
> > >http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: Table with 4 Milions of rows

2010-01-12 Thread nameless
My table with 4 milions of rows is queried often by ajax.
So I think a performance problems ( I am using also index ).
Ok now take a look at the contenttypes :)




On Jan 12, 8:15 pm, Tim  wrote:
> As far as needing to split up the table into other tables, I'm not
> sure. Whats wrong with having 4 million records in one table?
>
> But if you're going to do it, take a look at the contenttypes
> framework and generic relations. It basically does what you're
> describing:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Table with 4 Milions of rows

2010-01-12 Thread nameless

Hi at all. I have a project with 2 applications ( books and reader ).

Books application has a table with 4 milions of rows with this fields:

 book_title = models.CharField(max_length=40)
 book_description = models.CharField(max_length=400)

To avoid to query the database with 4 milions of rows, I am thinking
to divide it by subject ( 20 applications with 20 tables with 200.000
rows ( book_horror, book_drammatic, ecc ).

In "reader" application, I am thinking to insert this fields:

reader_name = models.CharField(max_length=20, blank=True)
book_subject = models.IntegerField()
book_id = models.IntegerField()

So instead of ForeignKey, I am thinking to use a integer
"book_subject" (which allows to access the appropriate table) and
"book_id" (which allows to access the table specified in the book
"book_subject").

Is a good solution to avoid to query a table with 4 milions of rows ?

Is there an alternative solution ?

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-us...@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 crypt python code

2010-01-11 Thread nameless
I have to upload my django project on shared hosting.
How can I crypt my code ?
I want to hide my code on server.

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-us...@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.




World cities database

2010-01-10 Thread nameless
Hi at all,
I need a world cities database for registration form.
What is the best and most used ?


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-us...@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: autocomplete widget

2010-01-09 Thread nameless
Thank you it's very useful.
Now I need to create a new widget in django but I don't know where is
the documentation about widget.


On Jan 9, 4:42 pm, "esatterwh...@wi.rr.com" <esatterwh...@wi.rr.com>
wrote:
> What I do for auto completers ( in general ) is point the widget at a
> URL that returns JSON objects and the parse the objects client side.
> For the user object your function might look like this:
>
> from django.utils import simplejson
> from django.contrib.auth.models import User
> from django.http import HttpResponse
>
> def ajax_get_users(request):
>  users  = User.objects.filter(username__istarstswith = request.POST
> ['q'])
>  return HttpResponse(simplejson.dumps([dict(username=u.username,
> id=u.pk) for u in users]), mimetype='text/javascript'))
>
> should get something that looks like this
>
> [
>    {username:'username',id:4},
>    {username:'username2',id:5}
> ]
>
> [urls.py]
> url(r'^/member/search/$', 'path.to.views.ajax_get_users',
> name="myapp_ajax_user_search"),
>
> if you have your widget set up to include the needed javascript that
> should be it. Honestly, the JS parts is more difficult than the django
> part.
>
> Hope that makes sense
> On Jan 8, 1:46 pm, nameless <xsatelli...@gmail.com> wrote:
>
> > Hi at all, I am looking for a working simple example on autocomplete
> > widget for foreign key in Django. I have found many example but I
> > don't understand and doesn't work.
>
> > This is my model:
>
> > class profile(models.Model):
>
> > user = models.ForeignKey(User, unique=True)
>
> > class profileForm(ModelForm):
>
> > user = forms.CharField(widget=AutoCompleteWidget())
>
> > class Meta:
> >     model = profile
>
> > I wish an AutoCompleteWidget working for this example.
>
> > Could anyone help me pleaseee ?
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




autocomplete widget

2010-01-08 Thread nameless
Hi at all, I am looking for a working simple example on autocomplete
widget for foreign key in Django. I have found many example but I
don't understand and doesn't work.

This is my model:

class profile(models.Model):

user = models.ForeignKey(User, unique=True)

class profileForm(ModelForm):

user = forms.CharField(widget=AutoCompleteWidget())

class Meta:
model = profile

I wish an AutoCompleteWidget working for this example.

Could anyone help me pleaseee ?
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Photo + thumbnail

2010-01-04 Thread nameless
Thank you. I have just writed this code.
It works but I want to avoit to save 2 times with "super(book,
self).save()" ( see below ):


from django.db import models
from PIL import Image
import glob, os

thumb_size = 90, 90

class book(models.Model):
title = models.CharField(max_length=200)
photo = models.ImageField(upload_to='photo_book')
thumb = models.ImageField(upload_to='thumb_book', blank=True,
null=True)



def save(self):
super(book, self).save()
file_path = self.photo.url
if (file_path):
im = Image.open(file_path)
im.thumbnail(thumb_size, Image.ANTIALIAS)
root, immagin = os.path.split(file_path)
immagin, ext = os.path.splitext(immagin)
im.save("thumb_book/" + immagin + ".thumbnail.jpg",
"JPEG")
self.thumb = "thumb_book/" + immagin + ".thumbnail.jpg"
super(book, self).save()




On Jan 4, 5:03 pm, Justin Myers <masterb...@gmail.com> wrote:
> I'm not able to test this idea directly myself at the moment, but it
> appears you're storing an absolute path (i.e., starting from the
> filesystem root) in self.thumb. I'm pretty sure FileFields (and, by
> extension, ImageFields) store relative paths from settings.MEDIA_ROOT.
>
> (To make sure I'm thinking about this properly (since again, I can't
> double-check this right now), you might want to see what the value of
> the thumb field is in the database first. If I'm right, you should see
> a path that consists of a relative path followed by an absolute one,
> such as "2010/0104//home/username/webapps/media/2010/0104/
> something.thumbnail.jpg".)
>
> An absolute path is certainly helpful for actually operating on the
> file, but before
> self.thumb = imfile + ".thumbnail.jpg"
> you'll need something like
> imfile, ext = os.path.splitext(self.photo)  # NOT .path, so this
> is a relative path, not an absolute one
> to make this work properly.
>
> Hope that helps.
> -Justin
>
> On Jan 4, 5:15 am, nameless <xsatelli...@gmail.com> wrote:
>
> > I have writed this code but it doesn't work. What is the error ?
>
> > from django.db import models
> > from django.forms import ModelForm
> > from PIL import Image
> > import glob, os
>
> > thumb_size = 90, 90
>
> > class book(models.Model):
> > title = models.CharField(max_length=200)
> > photo = models.ImageField(upload_to='bookphoto')
> > thumb = models.ImageField(upload_to='bookthumb')
>
> > def save(self):
>
> > file_path = self.photo.path
> > if (file_path):
> > imfile, ext = os.path.splitext(file_path)
> > im = Image.open(file_path)
> > im.thumbnail(thumb_size, Image.ANTIALIAS)
> > im.save(imfile + ".thumbnail.jpg", "JPEG")
> > self.thumb = imfile + ".thumbnail.jpg"
> > super(book, self).save()
>
> > class BookForm(ModelForm):
>
> > class Meta:
> > model = book
> > exclude = ('thumb',)
>
> > Please help me, I am going crazy :-\
>
> > --
>
> > On Jan 2, 5:17 pm, Xia Kai(夏恺) <xia...@gmail.com> wrote:
>
> > > Hi,
>
> > > This is a fantastic app, though it might be too fat for a minimalist like
> > > me.   ^_^
>
> > > I would recommend override the default save method of the model and resize
> > > the original photo using PIL. For the overriding part, you could consult 
> > > the
> > > documentation:http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-pre...
>
> > > 
> > > Xia Kai(夏恺)
> > > xia...@gmail.comhttp://blog.xiaket.org
>
> > > --
> > > From: "Chris Moffitt" <ch...@moffitts.net>
> > > Sent: Saturday, January 02, 2010 11:59 PM
> > > To: <django-users@googlegroups.com>
> > > Subject: Re: Photo + thumbnail
>
> > > > You'll probably want to use one of Django's thumbnail apps. Here's the 
> > > > one
> > > > I
> > > > recommend:
> > > >http://code.google.com/p/sorl-thumbnail/*
>
> > > > -*Chris
>
> > > > On Sat, Jan 2, 2010 at 9:48 AM, nameless <xsatelli...@gmail.com> wrote:
>
> > > >> Hi everyone I have a simple question.
> > > >> This is my model:
>
> > > >> class book(models.Model):
> > > >>title = models.CharField(max_length=50)
> > > >>photo = models.ImageField(upload_to='images/avatar/')
> > > >>thumb = models.ImageField(upload_to='images/thumb/')
>
> > > >> I want in photo original photo and in thumb the same photo but
> > > >> resized.
> > > >> How do I do that in simplest way ?
>
> > > >> Thank you and Good year  ^_^

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Photo + thumbnail

2010-01-04 Thread nameless
I have writed this code but it doesn't work. What is the error ?

from django.db import models
from django.forms import ModelForm
from PIL import Image
import glob, os

thumb_size = 90, 90

class book(models.Model):
title = models.CharField(max_length=200)
photo = models.ImageField(upload_to='bookphoto')
thumb = models.ImageField(upload_to='bookthumb')

def save(self):

file_path = self.photo.path
if (file_path):
imfile, ext = os.path.splitext(file_path)
im = Image.open(file_path)
im.thumbnail(thumb_size, Image.ANTIALIAS)
im.save(imfile + ".thumbnail.jpg", "JPEG")
self.thumb = imfile + ".thumbnail.jpg"
super(book, self).save()

class BookForm(ModelForm):

class Meta:
model = book
exclude = ('thumb',)

Please help me, I am going crazy :-\



--

On Jan 2, 5:17 pm, Xia Kai(夏恺) <xia...@gmail.com> wrote:
> Hi,
>
> This is a fantastic app, though it might be too fat for a minimalist like
> me.   ^_^
>
> I would recommend override the default save method of the model and resize
> the original photo using PIL. For the overriding part, you could consult the
> documentation:http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-pre...
>
> 
> Xia Kai(夏恺)
> xia...@gmail.comhttp://blog.xiaket.org
>
> --
> From: "Chris Moffitt" <ch...@moffitts.net>
> Sent: Saturday, January 02, 2010 11:59 PM
> To: <django-users@googlegroups.com>
> Subject: Re: Photo + thumbnail
>
> > You'll probably want to use one of Django's thumbnail apps. Here's the one
> > I
> > recommend:
> >http://code.google.com/p/sorl-thumbnail/*
>
> > -*Chris
>
> > On Sat, Jan 2, 2010 at 9:48 AM, nameless <xsatelli...@gmail.com> wrote:
>
> >> Hi everyone I have a simple question.
> >> This is my model:
>
> >> class book(models.Model):
> >>title = models.CharField(max_length=50)
> >>photo = models.ImageField(upload_to='images/avatar/')
> >>thumb = models.ImageField(upload_to='images/thumb/')
>
> >> I want in photo original photo and in thumb the same photo but
> >> resized.
> >> How do I do that in simplest way ?
>
> >> Thank you and Good year  ^_^

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Photo + thumbnail

2010-01-04 Thread nameless
I have writed this code but it doesn't work. What is the error ?


from django.db import models
from django.forms import ModelForm
from PIL import Image
import glob, os


thumb_size = 90, 90


class book(models.Model):
title = models.CharField(max_length=200)
photo = models.ImageField(upload_to='bookphoto')
thumb = models.ImageField(upload_to='bookthumb')



def save(self):

file_path = self.photo.path
if (file_path):
imfile, ext = os.path.splitext(file_path)
im = Image.open(file_path)
im.thumbnail(thumb_size, Image.ANTIALIAS)
im.save(immagin + ".thumbnail.jpg", "JPEG")
self.thumb = imfile + ".thumbnail.jpg"
super(book, self).save()


class BookForm(ModelForm):

class Meta:
model = book
exclude = ('thumb',)



Please help me, I am going crazy :-\


--

On Jan 2, 5:17 pm, Xia Kai(夏恺) <xia...@gmail.com> wrote:
> Hi,
>
> This is a fantastic app, though it might be too fat for a minimalist like
> me.   ^_^
>
> I would recommend override the default save method of the model and resize
> the original photo using PIL. For the overriding part, you could consult the
> documentation:http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-pre...
>
> 
> Xia Kai(夏恺)
> xia...@gmail.comhttp://blog.xiaket.org
>
> --
> From: "Chris Moffitt" <ch...@moffitts.net>
> Sent: Saturday, January 02, 2010 11:59 PM
> To: <django-users@googlegroups.com>
> Subject: Re: Photo + thumbnail
>
> > You'll probably want to use one of Django's thumbnail apps. Here's the one
> > I
> > recommend:
> >http://code.google.com/p/sorl-thumbnail/*
>
> > -*Chris
>
> > On Sat, Jan 2, 2010 at 9:48 AM, nameless <xsatelli...@gmail.com> wrote:
>
> >> Hi everyone I have a simple question.
> >> This is my model:
>
> >> class book(models.Model):
> >>    title = models.CharField(max_length=50)
> >>    photo = models.ImageField(upload_to='images/avatar/')
> >>    thumb = models.ImageField(upload_to='images/thumb/')
>
> >> I want in photo original photo and in thumb the same photo but
> >> resized.
> >> How do I do that in simplest way ?
>
> >> Thank you and Good year  ^_^

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 tutorial: TemplateDoesNotExist at /admin/

2010-01-04 Thread nameless
I have reinstalled django and now work ^_^



-

On Jan 3, 5:52 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Jan 3, 1:52 pm, nameless <xsatelli...@gmail.com> wrote:
>
>
>
> > I am using tutorial on django official documentation. But when I point
> > tohttp://127.0.0.1:8000/admin/, I get this error:
>
> > TemplateDoesNotExist at /admin/
>
> > admin/login.html
>
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type:         TemplateDoesNotExist
> > Exception Value:
>
> > admin/login.html
>
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> > template/loader.py in find_template_source, line 74
> > Python Executable:      /usr/bin/python
> > Python Version:         2.6.2
> > Python Path:    ['/home/nameless/Django-1.1.1/social', '/usr/lib/
> > python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-
> > tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/
> > usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/
> > Numeric', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/
> > dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/
> > lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/
> > python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
> > Server time:    Sun, 3 Jan 2010 07:47:21 -0600
> > Template-loader postmortem
>
> > Django tried loading these templates, in this order:
>
> >     * Using loader
> > django.template.loaders.filesystem.load_template_source:
> >     * Using loader
> > django.template.loaders.app_directories.load_template_source:
>
> > I am using Ubuntu 9.10 please help :-\
>
> Did you add 'django.contrib.admin' to INSTALLED_APPS in your
> settings.py?
> --
> DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 tutorial: TemplateDoesNotExist at /admin/

2010-01-03 Thread nameless
I have installed python and then django with setup.py install.
I have only one installation. What do I do ?

please help :-\




---
On Jan 3, 3:02 pm, Ramiro Morales <cra...@gmail.com> wrote:
> On Sun, Jan 3, 2010 at 10:52 AM, nameless <xsatelli...@gmail.com> wrote:
> > I am using tutorial on django official documentation. But when I point
> > tohttp://127.0.0.1:8000/admin/, I get this error:
>
> > TemplateDoesNotExist at /admin/
>
> > admin/login.html
>
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type:         TemplateDoesNotExist
> > Exception Value:
>
> > admin/login.html
>
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> > [...]
> > Python Path:    ['/home/nameless/Django-1.1.1/social', '/usr/lib/
>
> > I am using Ubuntu 9.10 please help :-\
>
> How have you installed Django?. Using a Ubuntu package (python-django)
> or did you perform an installation from source? Make sure you don't have
> more than one and possible incomplete installations.
>
> --
> Ramiro Morales  |  http://rmorales.net

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 tutorial: TemplateDoesNotExist at /admin/

2010-01-03 Thread nameless
I am using tutorial on django official documentation. But when I point
to http://127.0.0.1:8000/admin/ , I get this error:


TemplateDoesNotExist at /admin/

admin/login.html

Request Method: GET
Request URL:http://127.0.0.1:8000/admin/
Exception Type: TemplateDoesNotExist
Exception Value:

admin/login.html

Exception Location: /usr/local/lib/python2.6/dist-packages/django/
template/loader.py in find_template_source, line 74
Python Executable:  /usr/bin/python
Python Version: 2.6.2
Python Path:['/home/nameless/Django-1.1.1/social', '/usr/lib/
python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-
tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/
usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/
Numeric', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/
dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/
lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/
python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
Server time:Sun, 3 Jan 2010 07:47:21 -0600
Template-loader postmortem

Django tried loading these templates, in this order:

* Using loader
django.template.loaders.filesystem.load_template_source:
* Using loader
django.template.loaders.app_directories.load_template_source:




I am using Ubuntu 9.10 please help :-\

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Photo + thumbnail

2010-01-02 Thread nameless
Thank you but I want to do that without external apps if possible :)
I am looking for a simplest way to create a thumbnail automatically
when a new book is created.


--

On Jan 2, 4:59 pm, Chris Moffitt <ch...@moffitts.net> wrote:
> You'll probably want to use one of Django's thumbnail apps. Here's the one I
> recommend:http://code.google.com/p/sorl-thumbnail/*
>
> -*Chris
>
> On Sat, Jan 2, 2010 at 9:48 AM, nameless <xsatelli...@gmail.com> wrote:
> > Hi everyone I have a simple question.
> > This is my model:
>
> > class book(models.Model):
> >    title = models.CharField(max_length=50)
> >    photo = models.ImageField(upload_to='images/avatar/')
> >    thumb = models.ImageField(upload_to='images/thumb/')
>
> > I want in photo original photo and in thumb the same photo but
> > resized.
> > How do I do that in simplest way ?
>
> > Thank you and Good year  ^_^
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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.




Photo + thumbnail

2010-01-02 Thread nameless
Hi everyone I have a simple question.
This is my model:


class book(models.Model):
title = models.CharField(max_length=50)
photo = models.ImageField(upload_to='images/avatar/')
thumb = models.ImageField(upload_to='images/thumb/')



I want in photo original photo and in thumb the same photo but
resized.
How do I do that in simplest way ?




Thank you and Good year  ^_^

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.