Re: Trying to keep upload filename from disappearing - with python 2.7.1/django 1.2.4

2011-06-12 Thread Praveen Krishna R
*Perhaps you should try validating the other fields with javascript/jQuery
?!, *
*If it is something like Required Field validations...
*
On Fri, Jun 10, 2011 at 6:37 PM, djangobeginner wrote:

> I'm new to django and python but I'm working on a new screen for a
> project I'm on. The screen is supposed to capture a bunch of text
> information as well as allow a user to browse and select a file on
> their local machine for uploading. I'm having a problem with the
> filename disappearing from the selected filename textbox, whenever I
> submit the screen to begin uploading the file and I have an error on
> the screen. If I have an error on the screen the screen is returned
> showng an error message, but without the original filename selected
> being displayed (empty filename textbox), which will force the user to
> reselect the file again. Has anyone had this problem before, and if so
> how do I prevent the filename from disappearing? I have tried making a
> copy of the request.FILES similar to the way I have done previously
> with a request.POST (request.POST.copy()) capturing the filename data
> when entering my view, but when I try to add it back to the
> request.FILES by doing this in my error logic branch:
>
> request.FILES['filename'] = filename
>
> I get an AttributeError exception "can't set attribute". So since this
> doesn't work what is the proper way to do 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

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



headcut

2011-06-12 Thread francescortiz
Hi,

I developed a django app and I would like to know what you think about
it. I am relatively new to python and django so I expect more
criticism than enything else.

Description:
Django application that provides resizing and thumbnailing for images
and videos with the ability to set the center of attention, heads
won't get cut anymore.

Link:
https://github.com/francescortiz/image

I am thinking of calling it "django-headcut"

Thank you,

Francesc

-- 
You received this message because you are subscribed to the Google 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: Get all reverse related objects.

2011-06-12 Thread Marc Aymerich
On Sun, Jun 12, 2011 at 4:09 AM, Venkatraman S  wrote:
> On Sun, Jun 12, 2011 at 12:10 AM, Marc Aymerich  wrote:
>>
>> But, I'm wondering if django provides some generic mechanism to do the
>> invers relation? it is,given a Model_C object get all related Model_A
>> and Model_B objects.
>
> Like this :
> https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#reverse-generic-relations

Hi Venkatraman, with generic mechanism I wanted to say that the method
works for all models, maybe "dynamic mechanism" should be a better
name.

Anyway I write a method that does what i'm looking for.

get_related_FK(obj):
related_objects = []
for field in obj._meta.fields:
if field.__class__ is django.db.models.fields.related.ForeignKey:
 related_objects.append(getattr(obj, field.name))
return related_objects

I just wondering if django ships with something like that, just for
avoid reinvent the wheel.

-- 
Marc

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

2011-06-12 Thread Cal Leeming [Simplicity Media Ltd]
First, the good feedback.

Good use of exception blocks, code style, built-ins, standard libs etc..
Although I can't comment on the implementation on the end product, you have
clearly made an effort to use as many of the features offered by Django (and
python) as possible in this project. The fact you are using a decent code
repo (imo), is also a good sign. Though you still have a long way to go
(it's a never ending road lol), this is exceptionally good work for
a beginner.

And here's the criticisms / a few things that stand out..

Firstly:

path = path.replace("..", "")
path = path.replace("..", "")
(repeated 20 odd times)


Try replacing the above with os.path.basename() and os.path.abspath(), I
think a combination of both is what you are looking for (unless I've
mistaken what you were doing)

Secondly,


resp = ''
resp += ''
resp += ''


It is *extremely* bad practise to use string concatenation (even when
casting in-line). You should instead be using a sprintf style:

Example:

"""wrote:

> Hi,
>
> I developed a django app and I would like to know what you think about
> it. I am relatively new to python and django so I expect more
> criticism than enything else.
>
> Description:
> Django application that provides resizing and thumbnailing for images
> and videos with the ability to set the center of attention, heads
> won't get cut anymore.
>
> Link:
> https://github.com/francescortiz/image
>
> I am thinking of calling it "django-headcut"
>
> Thank you,
>
> Francesc
>
> --
> You received this message because you are subscribed to the Google 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: headcut

2011-06-12 Thread Cal Leeming [Simplicity Media Ltd]
Sorry, one last thing.

In relation to the resp html stuff, you should have actually used a template
for that, loaded the variables into a request context, then rendered the
template directly.

Cal


On Sun, Jun 12, 2011 at 6:18 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> First, the good feedback.
>
> Good use of exception blocks, code style, built-ins, standard libs etc..
> Although I can't comment on the implementation on the end product, you have
> clearly made an effort to use as many of the features offered by Django (and
> python) as possible in this project. The fact you are using a decent code
> repo (imo), is also a good sign. Though you still have a long way to go
> (it's a never ending road lol), this is exceptionally good work for
> a beginner.
>
> And here's the criticisms / a few things that stand out..
>
> Firstly:
>
>   path = path.replace("..", "")
>   path = path.replace("..", "")
> (repeated 20 odd times)
>
>
> Try replacing the above with os.path.basename() and os.path.abspath(), I
> think a combination of both is what you are looking for (unless I've
> mistaken what you were doing)
>
> Secondly,
>
>
> resp = ''
> resp += ' src="'+reverse('image.views.image',args=(value.image_path,'width=150&height=150&mode=scale'+extra_parms))+'"
>  onclick=""/>'
> resp += ' src="'+reverse('image.views.crosshair')+'" style="position:absolute; left:0; 
> top:0;" />'
>
>
> It is *extremely* bad practise to use string concatenation (even when
> casting in-line). You should instead be using a sprintf style:
>
> Example:
>
> """ class_name
> )
>
> or
>
> "
> etc
>
> Also, instead of using string appending (+=),you should instead append
> them to a list, then do a string join on the list ("\n".join(resp))
>
> Thirdly, I'm seeing a lack of RequestContext(), you should always include
> it (even if you don't use it), makes life easier in the future.
>
> Forthly, you are using a global within your code (global COUNTER). Using
> globals within a multi-threaded application is extremely bad, and can/will
> introduce undesirable race conditions. And believe me, this won't be the
> first or last time a race condition screws you over :)
>
> I see you are also using os.system(cmd), I would recommend looking into
> using popen instead.
>
> It might also be worth revisiting the code in a few days/weeks/months,
> looking over it, and making a list of things you dislike about it. As ones
> experience with any language progresses, their style changes slightly and
> they find better ways of doing things. The key to a great programmer, is not
> about making mistakes, but about recognising that you made one :) *imo
> anyway!*
>
> Hope this helps
>
> Cal
>
>
> On Sun, Jun 12, 2011 at 2:26 PM, francescortiz wrote:
>
>> Hi,
>>
>> I developed a django app and I would like to know what you think about
>> it. I am relatively new to python and django so I expect more
>> criticism than enything else.
>>
>> Description:
>> Django application that provides resizing and thumbnailing for images
>> and videos with the ability to set the center of attention, heads
>> won't get cut anymore.
>>
>> Link:
>> https://github.com/francescortiz/image
>>
>> I am thinking of calling it "django-headcut"
>>
>> Thank you,
>>
>> Francesc
>>
>> --
>> You received this message because you are subscribed to the Google 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: headcut

2011-06-12 Thread francescortiz
Cal,

Thank you for your feedback. I really appreciate it. I will be
implementing what you say as soon as I can. Everything you said was
pretty clear except the part from including a RequestContext. Where is
the RequestContext missing?

Also, about using a template instead of embedding HTML in the code, I
don't think I will be doing that unless it comes to be necessary (or
someone demands that), in order to save some function calls, like they
do in django widgets source code (if I didn't guess wrongly why they
do it this way).

Your comments are great. I will be fixing the race condition this next
week, and the rest of what you comment ASAP.

Regards,

Francesc



On 12 Juny, 19:19, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Sorry, one last thing.
>
> In relation to the resp html stuff, you should have actually used a template
> for that, loaded the variables into a request context, then rendered the
> template directly.
>
> Cal
>
> On Sun, Jun 12, 2011 at 6:18 PM, Cal Leeming [Simplicity Media Ltd] <
>
>
>
>
>
>
>
> cal.leem...@simplicitymedialtd.co.uk> wrote:
> > First, the good feedback.
>
> > Good use of exception blocks, code style, built-ins, standard libs etc..
> > Although I can't comment on the implementation on the end product, you have
> > clearly made an effort to use as many of the features offered by Django (and
> > python) as possible in this project. The fact you are using a decent code
> > repo (imo), is also a good sign. Though you still have a long way to go
> > (it's a never ending road lol), this is exceptionally good work for
> > a beginner.
>
> > And here's the criticisms / a few things that stand out..
>
> > Firstly:
>
> >    path = path.replace("..", "")
> >    path = path.replace("..", "")
> > (repeated 20 odd times)
>
> > Try replacing the above with os.path.basename() and os.path.abspath(), I
> > think a combination of both is what you are looking for (unless I've
> > mistaken what you were doing)
>
> > Secondly,
>
> >             resp = ''
> >             resp += ' > src="'+reverse('image.views.image',args=(value.image_path,'width=150&height=150&mode=scale'+extra_parms))+'"
> >  onclick=""/>'
> >             resp += ' > src="'+reverse('image.views.crosshair')+'" style="position:absolute; 
> > left:0; top:0;" />'
>
> > It is *extremely* bad practise to use string concatenation (even when
> > casting in-line). You should instead be using a sprintf style:
>
> > Example:
>
> > """ >     class_name
> > )
>
> > or
>
> > "
> > etc
>
> > Also, instead of using string appending (+=),you should instead append
> > them to a list, then do a string join on the list ("\n".join(resp))
>
> > Thirdly, I'm seeing a lack of RequestContext(), you should always include
> > it (even if you don't use it), makes life easier in the future.
>
> > Forthly, you are using a global within your code (global COUNTER). Using
> > globals within a multi-threaded application is extremely bad, and can/will
> > introduce undesirable race conditions. And believe me, this won't be the
> > first or last time a race condition screws you over :)
>
> > I see you are also using os.system(cmd), I would recommend looking into
> > using popen instead.
>
> > It might also be worth revisiting the code in a few days/weeks/months,
> > looking over it, and making a list of things you dislike about it. As ones
> > experience with any language progresses, their style changes slightly and
> > they find better ways of doing things. The key to a great programmer, is not
> > about making mistakes, but about recognising that you made one :) *imo
> > anyway!*
>
> > Hope this helps
>
> > Cal
>
> > On Sun, Jun 12, 2011 at 2:26 PM, francescortiz 
> > wrote:
>
> >> Hi,
>
> >> I developed a django app and I would like to know what you think about
> >> it. I am relatively new to python and django so I expect more
> >> criticism than enything else.
>
> >> Description:
> >> Django application that provides resizing and thumbnailing for images
> >> and videos with the ability to set the center of attention, heads
> >> won't get cut anymore.
>
> >> Link:
> >>https://github.com/francescortiz/image
>
> >> I am thinking of calling it "django-headcut"
>
> >> Thank you,
>
> >> Francesc
>
> >> --
> >> You received this message because you are subscribed to the Google 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.



ManyToMany field and deletes

2011-06-12 Thread Marc Aymerich
Hi ,
I realize that django doesn't delete related objects when M2M field
hasn't remaining relations. I don't see why django has this behaviour
by default.
I think it's a bit problematic because you can have 'orphan objects',
and more over a change form for this object will raise a validation
exception if you don't create a new relation.

Are anyone encouraged to explain a some good reason for this behavior? jeje
What is the best way to avoid this? maybe overriding the save method
but the down side of this is that admin delete confirmation page
doesn't will be aware of this. Is there any other option?

Thanks!

-- 
Marc

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

2011-06-12 Thread Cal Leeming [Simplicity Media Ltd]
On Sun, Jun 12, 2011 at 6:46 PM, francescortiz wrote:

> Cal,
>
> Thank you for your feedback. I really appreciate it. I will be
> implementing what you say as soon as I can. Everything you said was
> pretty clear except the part from including a RequestContext. Where is
> the RequestContext missing?
>

This was in relation to the template rendering comment, but without a
template then there's no need for request context.


>
> Also, about using a template instead of embedding HTML in the code, I
> don't think I will be doing that unless it comes to be necessary (or
> someone demands that), in order to save some function calls, like they
> do in django widgets source code (if I didn't guess wrongly why they
> do it this way).
>

Yeah, I guess it does, but you'd only really see the performance difference
if the method was getting 10k hits/sec (might be worth benchmarking it to
see what the perf diff actually is, it'd be a good learning experience!)


>
> Your comments are great. I will be fixing the race condition this next
> week, and the rest of what you comment ASAP.
>
> Regards,
>
> Francesc
>
>
>
> On 12 Juny, 19:19, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
> > Sorry, one last thing.
> >
> > In relation to the resp html stuff, you should have actually used a
> template
> > for that, loaded the variables into a request context, then rendered the
> > template directly.
> >
> > Cal
> >
> > On Sun, Jun 12, 2011 at 6:18 PM, Cal Leeming [Simplicity Media Ltd] <
> >
> >
> >
> >
> >
> >
> >
> > cal.leem...@simplicitymedialtd.co.uk> wrote:
> > > First, the good feedback.
> >
> > > Good use of exception blocks, code style, built-ins, standard libs
> etc..
> > > Although I can't comment on the implementation on the end product, you
> have
> > > clearly made an effort to use as many of the features offered by Django
> (and
> > > python) as possible in this project. The fact you are using a decent
> code
> > > repo (imo), is also a good sign. Though you still have a long way to go
> > > (it's a never ending road lol), this is exceptionally good work for
> > > a beginner.
> >
> > > And here's the criticisms / a few things that stand out..
> >
> > > Firstly:
> >
> > >path = path.replace("..", "")
> > >path = path.replace("..", "")
> > > (repeated 20 odd times)
> >
> > > Try replacing the above with os.path.basename() and os.path.abspath(),
> I
> > > think a combination of both is what you are looking for (unless I've
> > > mistaken what you were doing)
> >
> > > Secondly,
> >
> > > resp = ''
> > > resp += ' src="'+reverse('image.views.image',args=(value.image_path,'width=150&height=150&mode=scale'+extra_parms))+'"
> onclick=""/>'
> > > resp += ' src="'+reverse('image.views.crosshair')+'" style="position:absolute; left:0;
> top:0;" />'
> >
> > > It is *extremely* bad practise to use string concatenation (even when
> > > casting in-line). You should instead be using a sprintf style:
> >
> > > Example:
> >
> > > """ > > class_name
> > > )
> >
> > > or
> >
> > > " >
> > > etc
> >
> > > Also, instead of using string appending (+=),you should instead append
> > > them to a list, then do a string join on the list ("\n".join(resp))
> >
> > > Thirdly, I'm seeing a lack of RequestContext(), you should always
> include
> > > it (even if you don't use it), makes life easier in the future.
> >
> > > Forthly, you are using a global within your code (global COUNTER).
> Using
> > > globals within a multi-threaded application is extremely bad, and
> can/will
> > > introduce undesirable race conditions. And believe me, this won't be
> the
> > > first or last time a race condition screws you over :)
> >
> > > I see you are also using os.system(cmd), I would recommend looking into
> > > using popen instead.
> >
> > > It might also be worth revisiting the code in a few days/weeks/months,
> > > looking over it, and making a list of things you dislike about it. As
> ones
> > > experience with any language progresses, their style changes slightly
> and
> > > they find better ways of doing things. The key to a great programmer,
> is not
> > > about making mistakes, but about recognising that you made one :) *imo
> > > anyway!*
> >
> > > Hope this helps
> >
> > > Cal
> >
> > > On Sun, Jun 12, 2011 at 2:26 PM, francescortiz <
> francescor...@gmail.com>wrote:
> >
> > >> Hi,
> >
> > >> I developed a django app and I would like to know what you think about
> > >> it. I am relatively new to python and django so I expect more
> > >> criticism than enything else.
> >
> > >> Description:
> > >> Django application that provides resizing and thumbnailing for images
> > >> and videos with the ability to set the center of attention, heads
> > >> won't get cut anymore.
> >
> > >> Link:
> > >>https://github.com/francescortiz/image
> >
> > >> I am thinking of calling it "django-headcut"
> >
> > >> Thank you,
> >
> > >> Francesc
> >
> > >> --
> > >> You received this message because you are subscribed to 

Could not decode to UTF-8 column 'cpostal'

2011-06-12 Thread alexandre...@gmail.com
Hi,

I just converted a mssql database to sqlite3.
I used the folloing text_factory

con.text_factory = lambda x: x.decode('iso-8859-1').encode('utf-8')

that just converts from latin1 to utf-8
where i browse the tables in python shell it seems everything is fine
and well converted
but when in admin, I just get the error
"could not decode utf-8 column"

the columns django complains has the following data '4760 Vila Nova de
Famalic\xc3\xa3o   '

Any help appreciated.

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



Feed Parser, Community Aggregator, Date and Time settings

2011-06-12 Thread Chris McComas
I'm using the Django community aggregator on my site, which uses the
Universal Feed Parser to parse RSS feeds and save them in a database.

I noticed that the date_modified for feeds were actually +5 of my
timezone, which is set to America/Detroit in my Django settings. I'm
on DotCloud and unfortunately I'm not able to set any Environment
Variables (yet, they say they're working on that) and the default
timezone on there is UTC.

I don't mind that the field is saved in the database in the UTC
timezone, that's probably best. What I need to do, and have fought for
two days to do is convert it to Eastern Timezone when displayed on the
site. Also, I use the timesince template tag on a couple pages that
need to do a time since now to the feed item's date_modified both in
Eastern Timezone.

Any ideas? Suggestions?

-- 
You received this message because you are subscribed to the Google 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 template extends and include problem.

2011-06-12 Thread Korobase
test case as below:

1.base.html


{% block t1 %}
t
{% endblock %}



2.temp.html
{% block t2 %}
zzz
{% endblock %}

3.index.html
{% extends "base.html" %}
{% block t1 %}
kk
{% include "temp.html" %}
{% endblock %}

4.other.html
{% extends "index.html" %}
{% block t2 %}
qq
{% endblock %}


then,in the other.html,why I can't change the block t2?
how to implement this extends and modify its included block?

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.



How Django render the various templates?

2011-06-12 Thread Nge
Hi Everyone!

How can I create Django tablet site program?
How can decide Django redirect the web site or mobile site or tablet
site?
Does there has separately browser detection?

Thanks
Nge

-- 
You received this message because you are subscribed to the Google 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 getting this snippet to work in Django 1.2...

2011-06-12 Thread Alex Kamedov
It'll be better to use validators with IntegerField
https://docs.djangoproject.com/en/1.3/ref/models/fields/#validators
https://docs.djangoproject.com/en/1.3/ref/validators/

In this case you can specify allowed year range.


On Sat, Jun 11, 2011 at 9:25 AM, mhulse  wrote:

> Hi Martin! Thanks so much for the help, I really appreciate it. :)
>
>
> > The snippet is a form field, not a model field.
>
> Well, that would explain things! Lol.
>
> When I read this in the instructions:
>
> "Usage eg: yob = BirthYearField(label="What year were you born?")"
>
> I thought that was a model field.
>
> Thanks for pointing me in the right direction! :)
>
> Have a nice day.
>
>
> Cheers,
> Micky
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/BPbNW-I4VC8J.
>
> 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.
>



-- 
Alex Kamedov
skype: kamedovwww: kamedov.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.



how to do one-time passwords

2011-06-12 Thread Mike Dewhirst

I need a choice of login mechanisms ...

- Standard django-auth for some users

- SMS a one time password for other users

Would you think the following is the way to go? The user interface seems 
clunky to me. Any feedback will be greatly appreciated.



1. Enter the userid and optional password and submit
   (if it is standard django-auth user then process as normal)

2. If the userid is recognised as a one-time-password user ... if the 
password is absent or incorrect return a different error message saying 
to check the cellphone for a new password and try again.


2.1 Get output from a random password generator

2.2 Change the django-auth password and send it via SMS

3. If the userid is recognised as a one-time-password user ... if the 
password is correct then authenticate the user and change the password 
yet again so it is guaranteed incorrect for the next login.


Thanks

Mike

--
You received this message because you are subscribed to the Google 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: how to do one-time passwords

2011-06-12 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jun 13, 2011 at 6:36 AM, Mike Dewhirst wrote:

> I need a choice of login mechanisms ...
>
> - Standard django-auth for some users
>
> - SMS a one time password for other users
>
> Would you think the following is the way to go? The user interface seems
> clunky to me. Any feedback will be greatly appreciated.
>

As most users aren't used to having an 'otp' login, it's usually best to
allow the user to configure this within their profile. I am actually working
with a client at the moment to integrate SecurID tags with their Django
webapp, slightly different implementation, but same concept. The way we are
doing it with them, is only allowing the admin to attach the SecurID seed
key, giving the user the standard login screen, then once logged in, if it
requires OTP, it gives them a big security screen asking for the key.

Depending on the nature of your webapp, you may want to allow clients to
configure a phone number themselves, go through the confirmation steps, and
also offer some sort of override.


>
>
> 1. Enter the userid and optional password and submit
>   (if it is standard django-auth user then process as normal)
>
> 2. If the userid is recognised as a one-time-password user ... if the
> password is absent or incorrect return a different error message saying to
> check the cellphone for a new password and try again.
>
>2.1 Get output from a random password generator
>
>2.2 Change the django-auth password and send it via SMS
>
> 3. If the userid is recognised as a one-time-password user ... if the
> password is correct then authenticate the user and change the password yet
> again so it is guaranteed incorrect for the next login.
>

Actually changing the password to whatever is sent via SMS is not a good way
forward. Not only will this be db write-intensive if you scale out, but also
leaves you open to race conditions within the auth system, unless you have a
distributed objecting locking mechanism in place.

Ideally, you'd want to store the OTP (sent from SMS) in a caching server (or
db if you want to save it for retention purposes), validate the user again
their standard user/pass, then ask for the OTP once they have passed the
login screen.

The downside to this approach is that someone can at least find out if a
user/pass is valid, without needing the OTP, but can't get any further. If
you disliked this, you could ask for the OTP (without validating the
user/pass first), then validate it all in one chunk after they entered the
OTP. Personally, I'd prefer the first (at the slight loss of some security).

Hope this helps


> Thanks
>
> Mike
>
> --
> You received this message because you are subscribed to the Google 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: help plz to install Django

2011-06-12 Thread bh.hoseini
which step are u now ihsan?
did u installed django successfully & you're going to start a project?

Regards,

On Jun 11, 9:54 pm, Sergiy Khohlov  wrote:
> This guy would like to start. First steps are hard always and Are you
> definitely sure  that adding not trivial procedure is  a good solution
> ?  For the first steps  last version is not important, stable work and
> easy install are more important
>
>  Thanks,
> Serge
>
> 2011/6/12 Ignacio Soto :
>
>
>
>
>
>
>
> > Yes kennet is right, the version that is in the repos..maybe is not the
> > latest release version.
>
> > In ubuntu 11.04 is the 1.2 in repos,  you have to follow the install
> > instructions form the web page djangoproject.
>
> > Cheers
>
> > ignacio Soto Reveco
> > Staff IngeHost
>
> > El 11-06-2011 21:42, "Kenneth Gonsalves"  escribió:
>
> > On Sat, 2011-06-11 at 15:57 +0300, Sergiy Khohlov wrote:
> >> sudo apt-get search django
> >> sudo apt-get...
>
> > not good advice - *never* use the packaged version
> > --
> > 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 p...
>
> > --
> > You received this message because you are subscribed to the Google 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: Could not decode to UTF-8 column 'cpostal'

2011-06-12 Thread Cal Leeming [Simplicity Media Ltd]
I could be wrong, but I'm fairly sure that \xc3\xa3 is a 4 byte unicode
sequence (which is essentially UTF-16).

I'm not hot on understanding how unicode works, but I've had to deal with it
hundreds of times due to the nature of the webapps our company writes (most
data mining and indexing adapters).

You have a couple of options.

* Strip out all non convertible characters (errors=strip or errors=ignore
can't remember which)
* Convert all non convertible characters to the "?" sign (errors=replace)
* Use to_unicode_or_bust() - see http://pastebin.com/qrFk2zSp - not perfect
but does the job. (you'll also see a clean() in there which does stripping
of all 4 byte sequences).

For a better understanding of why this happens, I recommend looking at the
following:
https://github.com/kumar303/unicode-in-python

Something I've learned to accept in Python 2.*, is the complete and utter
lack of "appropriate" unicode handling. By this, I mean that tasks which
should be relatively simple, are not.

We ended up making a String() object which did all these appropriate sanity
checks (based on the pastebin link above) and we have never had problems
since.

Hope this helps

Cal
Cal

On Sun, Jun 12, 2011 at 11:31 PM, alexandre...@gmail.com <
alexandre...@gmail.com> wrote:

> Hi,
>
> I just converted a mssql database to sqlite3.
> I used the folloing text_factory
>
> con.text_factory = lambda x: x.decode('iso-8859-1').encode('utf-8')
>
> that just converts from latin1 to utf-8
> where i browse the tables in python shell it seems everything is fine
> and well converted
> but when in admin, I just get the error
> "could not decode utf-8 column"
>
> the columns django complains has the following data '4760 Vila Nova de
> Famalic\xc3\xa3o   '
>
> Any help appreciated.
>
> --
> You received this message because you are subscribed to the Google 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.