Re: form CharField null vs blank

2011-04-28 Thread bjornsteinarfjeldpetter...@gmail.com
On Apr 29, 7:25 am, Michael Radziej  wrote:
> On Thu, 28 Apr 2011 06:18:08 -0700, Brian Craft  
> wrote:
> > A form with a CharField seems to end up with a zero-length string in
> > the cleaned_data if the field is not in the form data. Is there any
> > good way to avoid this?
>
> Django docs say:
>
> "Note that empty string values will always get stored as empty strings,
> not as NULL. Only use null=True for non-string fields such as integers,
> booleans and dates. For both types of fields, you will also need to set
> blank=True if you wish to permit empty values in forms, as the null
> parameter only affects database storage (see blank).
>
> Avoid using null on string-based fields such as CharField and TextField
> unless you have an excellent reason. If a string-based field has
> null=True, that means it has two possible values for “no data”: NULL,
> and the empty string. [...]

This is of course technically incorrect :-)

NULL means that you don't have any information, the empty string means
that you _know_ that the value is a string of length zero.  This is
basic information theory.

Django is in good company though, most databases have problems round-
tripping one or more of the values NULL, "" (empty string), and " "
single space.  What Django is doing is abstracting away inconsistent
database behavior -- and that's a good thing.

-- bjorn

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



Re: form CharField null vs blank

2011-04-28 Thread Michael Radziej
On Thu, 28 Apr 2011 06:18:08 -0700, Brian Craft  
wrote:
> A form with a CharField seems to end up with a zero-length string in
> the cleaned_data if the field is not in the form data. Is there any
> good way to avoid this?

Django docs say:

"Note that empty string values will always get stored as empty strings,
not as NULL. Only use null=True for non-string fields such as integers,
booleans and dates. For both types of fields, you will also need to set
blank=True if you wish to permit empty values in forms, as the null
parameter only affects database storage (see blank).

Avoid using null on string-based fields such as CharField and TextField
unless you have an excellent reason. If a string-based field has
null=True, that means it has two possible values for “no data”: NULL,
and the empty string. In most cases, it’s redundant to have two possible
values for “no data;” Django convention is to use the empty string, not
NULL."


If you really need to get NULL, you've got to do this with your own
validators.

Kind regards

Michael

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



Re: Unicode problems

2011-04-28 Thread Michael Radziej
On Thu, 28 Apr 2011 00:49:40 -0300, Daniel França  
wrote:
> I'm getting a lot of problems saving and reading from files with special
> characteres in name, using the django-avatar lib.
> 
> The truth is that I don't really understand the way python/django handle
> unicodes, for example, I suspect that from the moment the trace tells me
> that there's some strange characters in my variable I can't do anything
> anymore... like try to use the unicode() method.

Ah, you need to make yourself familiar with Python's unicode
support. The problems arise as soon as one of your users enters
non-ASCII-characters e.g. as file name.

In Django, all strings that go into the database must be unicode
strings and will be converted to unicode strings if they are not. This
fails as soon as there are non-ASCII-characters in the string.

I can recommend for reading:

http://www.joelonsoftware.com/articles/Unicode.html
http://www.stereoplex.com/blog/python-unicode-and-unicodedecodeerror
http://docs.python.org/howto/unicode.html

It's nothing about Django, just Python.

Hope that helps a bit.


Kind regards

Michael

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



Re: cx_Oracle error: ImproperlyConfigured

2011-04-28 Thread kamal sharma
Yes you are correct, that the reason i have replaced the below line in
"app.wsgi", but that does not works.

#os.environ["LD_LIBRARY_PATH"] = "/opt/app/oracle/products/11.2.0/lib"
#os.environ["ORACLE_HOME"] = "/opt/app/oracle/products/11.2.0"

os.environ["LD_LIBRARY_PATH"] = "/opt/app/oracle/products/10.2.0/lib"
os.environ["ORACLE_HOME"] = "/opt/app/oracle/products/10.2.0"

Thanks,



On Fri, Apr 29, 2011 at 2:10 AM, Jirka Vejrazka wrote:

> Kamal, this is exactly the same error you were getting before. Are you
> sure that you have ORACLE_HOME properly set on your new client and in
> the right environment?
>
>  Cheers
>
>  Jirka
>
> On 28/04/2011, kamal sharma  wrote:
> > Hi Again,
> >
> > I have finished my implementation with the local db, but now stuck in
> major
> > issue.When i try to login to the local oracle database then it is working
> > perfectly fine.I am able to read the data from the db installed in the
> > same UNIX machine.
> >
> > But when i tried to login a db installed in remote machine, which is
> > installed in the client side, then getting following error.
> >
> > Traceback (most recent call last):
> >   File "test_db.py", line 8, in ?
> > connection = cx_Oracle.Connection("%s/%s@%s" % ('user', 'user123',
> > 'db'))
> > cx_Oracle.DatabaseError: ORA-01804: failure to initialize timezone
> > information
> >
> > Also at the client machine the Oracle is (10.2.0)
> > "/opt/app/oracle/products/10.2.0", but in my machine it
> > is /opt/app/oracle/products/11.2.0 (11.2.0).
> >
> >
> > Earlier i was using like this in my CGI-Perl code, now i have to migrate
> > this in Django-Python module to use the below logic.How we can solve this
> > problem?
> >
> > # Add ORACLE_HOME for 10g Oracle client.
> > BEGIN { $ENV{ORACLE_HOME} = '/opt/app/oracle/products/10.2.0' }
> >
> > Any help will be highly appreciated.
> >
> > Thanks,
> > Kamal
> >
> > On Tue, Apr 26, 2011 at 10:22 PM, kamal sharma
> > wrote:
> >
> >> Thanks to all for supporting this to fix the issue.
> >>
> >> So issue is resolved by adding these 2 lines in "app.wsgi"
> >>
> >> os.environ["LD_LIBRARY_PATH"] = "/opt/app/oracle/products/11.2.0/lib"
> >> os.environ["ORACLE_HOME"] = "/opt/app/oracle/products/11.2.0"
> >>
> >> Thanks again for helping to fix this issue. Its really a superb forum to
> >> fix the issue so quickly. :-)
> >>
> >> Regards,
> >> Kamal
> >>
> >> On Sun, Apr 24, 2011 at 7:58 PM, Ian  wrote:
> >>
> >>> On Apr 23, 12:29 pm, kamal sharma  wrote:
> >>> > No it was .profile of mine. Now I have set the LD_LIBRARY_PATH in
> >>> app.wsgi
> >>> > as mentioned below and when I print the os.environ in the beginning
> of
> >>> > views.py then it shows that newly added value.
> >>>
> >>> It's clear that your LD_LIBRARY_PATH is fine at this point, since the
> >>> library must be loaded in order to get the ORA-01804 error.  The
> >>> problem, as Jirka and I have suggested, is that the rest of your
> >>> Oracle installation is still not visible to the process, which is
> >>> preventing the client from reading its data files.  Why this is the
> >>> case is unclear without knowing more details about your system.  Is
> >>> the Oracle directory readable by the WSGI user?  Is the WSGI process
> >>> running inside a chroot jail?
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Django users" group.
> >>> To post to this group, send email to django-users@googlegroups.com.
> >>> To unsubscribe from this group, 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: Using User.add_to_class

2011-04-28 Thread Venkatraman S
Resending :


On Wed, Apr 27, 2011 at 4:13 PM, Venkatraman S  wrote:

> Hi,
>
> In my app, i have many functions added to the User class using
> User.add_to_class ; these are basically the functions that restrict the
> objects that can be viewed by the user during his session with the app. The
> functions are present in __init__.py in my project.
>
> My Q : is this a good paradigm to do things? i.e, restricting the user's
> workspace. Or is it better that i do the DB queries in my views - apply
> filter on the queries there.
> Which is a better model and would scale?(and also be easier if i implement
> caching in the near future).
>
> IMHO, i find User.add_to_class to be extremely useful and the code is much
> easier to maintain; but since this is a paradigm Q, i would let the more
> experienced answer this.
>
> -Venkat
> http://blizzardzblogs.blogspot.com/
>

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



staticfiles - media and static folders, any way to avoid duplicated content?

2011-04-28 Thread Aljoša Mohorović
if i support both staticfiles and django.contrib.staticfiles i need to
copy content from media folder to static folder so when i create a
python package i have media and static folders with the same content.
any way to avoid this and still support both?

Aljosa Mohorovic

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Is there a more basic tutorial?

2011-04-28 Thread byront
I understand, thanks for the advice everyone. -Byron

On Apr 26, 5:24 pm, Lachlan Musicman  wrote:
> On Wed, Apr 27, 2011 at 04:34, byront  wrote:
> > Hello,
>
> > I went through the beginners tutorial and am interested in Django. I
> > new to web development altogether and am having trouble finding
> > resources to help me make a very basic but professional looking page.
> > Something similar to this yacht club pagehttp://bhyc.on.ca/with a
> > banner, menus that change on scroll over, several static pages, and a
> > front page with rotating information.
>
> > Any help would be greatly appreciated.
>
> As Shawn says, the underlying HTML and CSS is probably a good place to
> start for an understanding of how the whole web system works. Django
> is what I would call a third generation web dev platform, with first
> gen being html/css via notepad or nvu/dreamweaver. Second generation
> would be the CMS mob: wordpress, joomla, drupal, etc.
>
> None of these will really help you witha lot of the other stuff you
> will need to know - web servers (apache, nginx, lighttpd), CGI, etc.
> If you are not a computer scientist or not planning on being one, and
> want simple: try wordpress. If you are planning on being a computer
> scientist of some description, learn html and css (and then move onto
> django).
>
> cheers
> L.
>
> --
> Bacon ice cream (or Bacon-and-egg ice cream) is a modern invention in
> experimental cookery, generally created by adding bacon to egg custard
> and freezing the mixture. Although it was a joke in a Two Ronnies
> sketch, it was eventually created for April Fools’ Day. Heston
> Blumenthal experimented with the creation of ice cream, making a
> custard similar to scrambled eggs then adding bacon to create one of
> his signature dishes. It now regularly appears on dessert menus in
> high-end restaurants.
> from The Best of Wikipediahttp://bestofwikipedia.tumblr.com/

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



Question about "Django 1.1 Testing and Debugging" Book for Karen

2011-04-28 Thread Margie Roginski
Hi Karen,

I have a bit of time on my hands and was going to run through your
book to cement my understanding of the best way to test.  I started
out and was immediately confronted with the fact that there seem to be
some differences between django 1.1 and django 1.2 in terms of
testing. At a minimum, it seems that tests.py doesn't get even get
created by startapp anymore!

In some quick review of the 1.2 doc, it seems like perhaps there are
other changes as well.

I was just wondering if you have any sort of addendum, even in some
informal form that would bring your book up to date with django 1.2.?
Or maybe the changes between 1.1 and 1.2 are just very minor?  I see
something about "class based test runners" in the doc.  I haven't
really had a chance to dive in yet, but just thought I'd ask if you
have any updates you'd be willing to provide.

Thanks,

Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 i connect my PostgreeSQL to a Django?

2011-04-28 Thread Flaviu Simihaian
Lucas,

Check this resource out: 
http://docs.djangoproject.com/en/1.3/intro/tutorial01/#database-setup

It's best to start with sqlite3 and make sure that works, then look at
installing PostgreSQL or MySQL.

I wrote a quick and dirty setup of Postgres on an OS X dev
environment: http://readncode.com/blog/set-up-postgresql-on-mac-os-quickly/

But it's no replacement for the comprehensive Postgres docs:
http://www.postgresql.org/docs/9.0/interactive/tutorial-start.html

-Flaviu

On Apr 27, 9:07 am, Web Lucas  wrote:
> well,
>
> I unnistall the PostgreeSQL and install MySQL
>
> you can help me with the configuration ?
>
> Thanks
>
> On 26 abr, 15:40, Shawn Milochik  wrote:
>
>
>
>
>
>
>
> > What error are you getting?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: cx_Oracle error: ImproperlyConfigured

2011-04-28 Thread kamal sharma
Hi Again,

I have finished my implementation with the local db, but now stuck in major
issue.When i try to login to the local oracle database then it is working
perfectly fine.I am able to read the data from the db installed in the
same UNIX machine.

But when i tried to login a db installed in remote machine, which is
installed in the client side, then getting following error.

Traceback (most recent call last):
  File "test_db.py", line 8, in ?
connection = cx_Oracle.Connection("%s/%s@%s" % ('user', 'user123',
'db'))
cx_Oracle.DatabaseError: ORA-01804: failure to initialize timezone
information

Also at the client machine the Oracle is (10.2.0)
"/opt/app/oracle/products/10.2.0", but in my machine it
is /opt/app/oracle/products/11.2.0 (11.2.0).


Earlier i was using like this in my CGI-Perl code, now i have to migrate
this in Django-Python module to use the below logic.How we can solve this
problem?

# Add ORACLE_HOME for 10g Oracle client.
BEGIN { $ENV{ORACLE_HOME} = '/opt/app/oracle/products/10.2.0' }

Any help will be highly appreciated.

Thanks,
Kamal

On Tue, Apr 26, 2011 at 10:22 PM, kamal sharma wrote:

> Thanks to all for supporting this to fix the issue.
>
> So issue is resolved by adding these 2 lines in "app.wsgi"
>
> os.environ["LD_LIBRARY_PATH"] = "/opt/app/oracle/products/11.2.0/lib"
> os.environ["ORACLE_HOME"] = "/opt/app/oracle/products/11.2.0"
>
> Thanks again for helping to fix this issue. Its really a superb forum to
> fix the issue so quickly. :-)
>
> Regards,
> Kamal
>
> On Sun, Apr 24, 2011 at 7:58 PM, Ian  wrote:
>
>> On Apr 23, 12:29 pm, kamal sharma  wrote:
>> > No it was .profile of mine. Now I have set the LD_LIBRARY_PATH in
>> app.wsgi
>> > as mentioned below and when I print the os.environ in the beginning of
>> > views.py then it shows that newly added value.
>>
>> It's clear that your LD_LIBRARY_PATH is fine at this point, since the
>> library must be loaded in order to get the ORA-01804 error.  The
>> problem, as Jirka and I have suggested, is that the rest of your
>> Oracle installation is still not visible to the process, which is
>> preventing the client from reading its data files.  Why this is the
>> case is unclear without knowing more details about your system.  Is
>> the Oracle directory readable by the WSGI user?  Is the WSGI process
>> running inside a chroot jail?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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: Transform words into links with regex

2011-04-28 Thread Shawn Milochik
You need to use mark_safe. Otherwise Django will be protecting you from 
potential malicious input.


http://docs.djangoproject.com/en/1.3/ref/utils/#django.utils.safestring.mark_safe

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



Transform words into links with regex

2011-04-28 Thread martinez
Hello. I am using Django 1.3 on Windows XP.
I read a tutorial and the code below transforms the words like MyLink
into a html link.
But the output that I achieved is the HTML markups of the link, not
the link itself.
How to solve that?
Thank you.

wikilink = re.compile("\\b([A-Z][a-z]+[A-Z][a-z]+)\\b")

register = template.Library()

@register.filter
def wikify(value):
return wikilink.sub(r"\1",value)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: URLs in error messages from form validation

2011-04-28 Thread Derek
On Apr 28, 12:33 pm, Tom Evans  wrote:
> On Mon, Apr 25, 2011 at 11:40 PM, Daniel Gerzo  wrote:
> > PS: I'm just wondering where did you find this? I was looking around the
> > documentation and was unable to get any trace of such a function...
>
> http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.s...
>

And if you have written your own tags, you would have come across it
here:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping

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



Override a static file.

2011-04-28 Thread Fabian Ezequiel Gallina
Hey folks,

I'm wondering if there is any preferred way to override staticfiles.

The use case is that I modified some grapelli static file and I would
like my version of it to be the final one after collectstatic is run.



Regards,
-- 
Fabián E. Gallina
http://www.anue.biz

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



Uploaded file in django doesn't have RIFF id

2011-04-28 Thread Rafał Łużyński
I upload .wav file to django, and problem is that lib wave from
python, can't open it 'cause it doesnt have RIFF id. I made this test:

print request.FILES['file'].read(20)
f = open('C:/audio_test/Cricket.wav')
print f.read(20)
validation, error = sa.validation(request.FILES['file'])

I print first 20 bytes of uploaded file, and then 20 bytes of file
directly from hdd.

Output:

♠ WAVEfmt ↕   ☺ ☺ DČ
RIFF~╚♠ WAVEfmt ↕

As we can see django loses first 6 bytes of file somewhere. I dont
know why, and I cant make wave lib works without it.

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



RE: This section is converting database table to excel file

2011-04-28 Thread Sells, Fred
Since Excel will import a csv file, why not just write a csv file.  In mysql, 
while ugly, you could shell down and use the mysql command line options to 
export a query to csv.

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Od-Erdene Ch
Sent: Thursday, April 28, 2011 6:23 AM
To: django-users@googlegroups.com
Subject: This section is converting database table to excel file

 

hi there

this section is converting database table to excel file.

 

problem is when converting database table to excel file (it is containing 6400 
[six thousand four hundred] rows) it is spending more than 10 minutes.

that is very slow. is there any idea to make more faster. Help me

 

 

CODE:

 

if request.GET.has_key('excel') :

if request.GET['excel'] == "true":

qs = CarDetails.objects.all().order_by(sord + sidx)

wb = xlwt.Workbook()

ws = wb.add_sheet(u'CarDetails')

labels = [u"型式", u"車名", 
u"車輌詳細コード",u'車体形状',u"類別区分番号",u"車輌重量諸元",u"全長",

  u"全幅",u"全高",u"用途",u"形状",u"原動機型式",u"総排気量",u"営・自家用区分",

  u"乗車定員",u"最大積載量",u"車輌総重量",u"燃料の種類",u"乗車定員括弧",u"最大積載量括弧",

  u"ローター数",u"燃料種類",u"燃料種類括弧 その他"]



ws.write_merge(0, 0, 0, 22, u'車輌マスター管理', get_title_style())



label_style = get_label_style2()

for i in range(len(labels)) :

ws.write(1, i, labels[i], label_style)

ws.col(0).width = get_computed_width(-30) # by pixel

ws.col(1).width = get_computed_width(150)

ws.col(2).width = get_computed_width(150)

ws.col(3).width = get_computed_width(150)

ws.col(4).width = get_computed_width(150)

ws.col(5).width = get_computed_width(150)

ws.col(6).width = get_computed_width(150)

ws.col(7).width = get_computed_width(150)

ws.col(8).width = get_computed_width(150)

ws.col(9).width = get_computed_width(150)

ws.col(10).width = get_computed_width(150)

ws.col(11).width = get_computed_width(150)

ws.col(12).width = get_computed_width(150)

ws.col(13).width = get_computed_width(150)

ws.col(14).width = get_computed_width(150)

ws.col(15).width = get_computed_width(150)

ws.col(16).width = get_computed_width(150)

ws.col(17).width = get_computed_width(150)

ws.col(18).width = get_computed_width(150)

ws.col(19).width = get_computed_width(150)

ws.col(20).width = get_computed_width(150)

ws.col(21).width = get_computed_width(150)

ws.col(22).width = get_computed_width(150)

today = datetime.strftime(datetime.today(),"%Y-%m-%d")

rown = 2

simple_style = get_simple_style()

 

for list in qs :

car_maker_code = ""

car_maker = ""

car_name2 = ""

tax = ""

model = ""

car_name = ""

name = ""

body = ""

class_type_number = ""

weight = ""

length = ""

width = ""

height = ""

usage = ""

view_type = ""

motor_type = ""

totol_piston_cc = ""

is_own = ""

human_size = ""

kg_size = ""

totol_weight = ""

fuel_type = ""

human_size_kakko = ""

kg_size_kakko = ""

rotor_number = ""

fuel_type_kakko = ""

fuel_type_kakko_sonota = ""

if list.model: model = list.model

if list.carname: car_name = list.carname

if list.name: name = list.name

if list.body: body = list.body

if list.class_type_number: class_type_number = 
list.class_type_number

if list.weight: weight = list.weight

if list.length: length = list.length

if list.width: width = list.width

if list.height: height = list.height

if list.usage: usage = list.get_usage_display()

if list.view_type: view_type = list.view_type

if list.motor_type: motor_type = list.motor_type

if list.totol_piston_cc: totol_piston_cc = list.totol_piston_cc

if list.is_own: is_own = list.get_is_own_display()

if list.human_size: human_size = list.human_size

if list.kg_size: kg_size = list.kg_size

if list.totol_weight: totol_weight = list.totol_weight

if list.fuel_type: fuel_type = list.get_fuel_type_display()

if list.human_size_kakko: 

form CharField null vs blank

2011-04-28 Thread Brian Craft
A form with a CharField seems to end up with a zero-length string in
the cleaned_data if the field is not in the form data. Is there any
good way to avoid this?

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



Re: Extremely Frustrated

2011-04-28 Thread Brian Bouterse
Also while in vim, you can show all symbols in the file directly as symbols.
 This makes tabs versus spaces trivial to identify.  To enter this mode use
the following command in vim.

:set list

and to exit this mode use

:set nolist

See the documentation
here
.

Brian


On Thu, Apr 28, 2011 at 4:50 AM, Tom Evans  wrote:

> On Thu, Apr 28, 2011 at 8:47 AM, Kenneth Gonsalves
>  wrote:
> > On Thu, 2011-04-28 at 00:27 -0700, Derek wrote:
> >> A good IDE will convert tabs to spaces for you save you hours of
> >> frustration!
> >
> > tab-nanny is also your friend
>
> Or in vim:
> :set expandtab shiftwidth=4 tabstop=4 | retab
>
> Short form:
> :se et sw=4 ts=4 | ret
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: pycharm change django project directory

2011-04-28 Thread Xavier Ordoquy
Hi,

I also use pycharm.
Go in the configuration / Django Support  and fills the fields (including 
enable django support).
Looks like it has not been reconized out of the box since the django project 
seems to be in your subdirectories and there seems to be more than one project.

Regards,
Xavier.

Le 28 avr. 2011 à 11:55, SK a écrit :

> I clone a directory from hg in pycharm
> such like this:
> 
> directory (clone from this level)
>doc
>server
>webs
>d_web1(this is a django project)
>d_web2(another django project)
>...
> 
> the d_web1 can't be recognized as a django project in pycharm
> 
> anyone can help me, thx
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



pycharm change django project directory

2011-04-28 Thread SK
I clone a directory from hg in pycharm
such like this:

directory (clone from this level)
doc
server
webs
d_web1(this is a django project)
d_web2(another django project)
...

the d_web1 can't be recognized as a django project in pycharm

anyone can help me, thx

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: annotate() for subgroups within a column

2011-04-28 Thread Tom Evans
On Thu, Apr 21, 2011 at 9:22 PM, Ariana  wrote:
> Hi everyone,
>
>
>
> If it helps at all, this could be accomplished with the following SQL:
>
> SELECT updatee, score, id
>   FROM Update
>   WHERE lastUpdated = (
>       SELECT max(lastUpdated)
>       FROM Update as u
>       WHERE u.updatee = Update.updatee)
>
> I am really stumped on how to accomplish this in Django, and would
> prefer not to use raw SQL if I can help it. Can anyone point me in the
> right direction?
>

Django's ORM is not a universal panacea for dealing with the database.
Complex things like this still require you to be able to use SQL.

Fortunately, you can use raw SQL and django's ORM to return model
instances from your raw query:

http://docs.djangoproject.com/en/1.3/topics/db/sql/


Cheers

Tom

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



Re: URLs in error messages from form validation

2011-04-28 Thread Tom Evans
On Mon, Apr 25, 2011 at 11:40 PM, Daniel Gerzo  wrote:
> PS: I'm just wondering where did you find this? I was looking around the
> documentation and was unable to get any trace of such a function...
>

http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.safestring

Cheers

Tom

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



This section is converting database table to excel file

2011-04-28 Thread Od-Erdene Ch
*hi there*
*this section is converting database table to excel file.*

*problem is when converting database table to excel file (it is containing
6400 [six thousand four hundred] rows) it is spending more than 10 minutes.*
*that is very slow. is there any idea to make more faster. Help me*


*CODE:*
*
*
if request.GET.has_key('excel') :
if request.GET['excel'] == "true":
qs = CarDetails.objects.all().order_by(sord + sidx)
wb = xlwt.Workbook()
ws = wb.add_sheet(u'CarDetails')
labels = [u"型式", u"車名",
u"車輌詳細コード",u'車体形状',u"類別区分番号",u"車輌重量諸元",u"全長",
  u"全幅",u"全高",u"用途",u"形状",u"原動機型式",u"総排気量",u"営・自家用区分",

u"乗車定員",u"最大積載量",u"車輌総重量",u"燃料の種類",u"乗車定員括弧",u"最大積載量括弧",
  u"ローター数",u"燃料種類",u"燃料種類括弧 その他"]

ws.write_merge(0, 0, 0, 22, u'車輌マスター管理', get_title_style())

label_style = get_label_style2()
for i in range(len(labels)) :
ws.write(1, i, labels[i], label_style)
ws.col(0).width = get_computed_width(-30) # by pixel
ws.col(1).width = get_computed_width(150)
ws.col(2).width = get_computed_width(150)
ws.col(3).width = get_computed_width(150)
ws.col(4).width = get_computed_width(150)
ws.col(5).width = get_computed_width(150)
ws.col(6).width = get_computed_width(150)
ws.col(7).width = get_computed_width(150)
ws.col(8).width = get_computed_width(150)
ws.col(9).width = get_computed_width(150)
ws.col(10).width = get_computed_width(150)
ws.col(11).width = get_computed_width(150)
ws.col(12).width = get_computed_width(150)
ws.col(13).width = get_computed_width(150)
ws.col(14).width = get_computed_width(150)
ws.col(15).width = get_computed_width(150)
ws.col(16).width = get_computed_width(150)
ws.col(17).width = get_computed_width(150)
ws.col(18).width = get_computed_width(150)
ws.col(19).width = get_computed_width(150)
ws.col(20).width = get_computed_width(150)
ws.col(21).width = get_computed_width(150)
ws.col(22).width = get_computed_width(150)
today = datetime.strftime(datetime.today(),"%Y-%m-%d")
rown = 2
simple_style = get_simple_style()

for list in qs :
car_maker_code = ""
car_maker = ""
car_name2 = ""
tax = ""
model = ""
car_name = ""
name = ""
body = ""
class_type_number = ""
weight = ""
length = ""
width = ""
height = ""
usage = ""
view_type = ""
motor_type = ""
totol_piston_cc = ""
is_own = ""
human_size = ""
kg_size = ""
totol_weight = ""
fuel_type = ""
human_size_kakko = ""
kg_size_kakko = ""
rotor_number = ""
fuel_type_kakko = ""
fuel_type_kakko_sonota = ""
if list.model: model = list.model
if list.carname: car_name = list.carname
if list.name: name = list.name
if list.body: body = list.body
if list.class_type_number: class_type_number =
list.class_type_number
if list.weight: weight = list.weight
if list.length: length = list.length
if list.width: width = list.width
if list.height: height = list.height
if list.usage: usage = list.get_usage_display()
if list.view_type: view_type = list.view_type
if list.motor_type: motor_type = list.motor_type
if list.totol_piston_cc: totol_piston_cc =
list.totol_piston_cc
if list.is_own: is_own = list.get_is_own_display()
if list.human_size: human_size = list.human_size
if list.kg_size: kg_size = list.kg_size
if list.totol_weight: totol_weight = list.totol_weight
if list.fuel_type: fuel_type = list.get_fuel_type_display()
if list.human_size_kakko: human_size_kakko =
list.human_size_kakko
if list.kg_size_kakko: kg_size_kakko = list.kg_size_kakko
if list.rotor_number: rotor_number = list.rotor_number
if list.fuel_type_kakko: fuel_type_kakko =
list.fuel_type_kakko
if list.fuel_type_kakko_sonota: fuel_type_kakko_sonota =
list.fuel_type_kakko_sonota

ws.write(rown, 0, unicode(model), simple_style)
ws.write(rown, 1, unicode(car_name), simple_style)
ws.write(rown, 2, unicode(name), simple_style)
   

Re: Double security login system

2011-04-28 Thread Mike Ryan
There is some discussion of two-factor auth systems in Django over at
StackOverflow [1]. One of the answers links to an example app that
implements two-factor auth [2], which sounds pretty close to what you
are looking for (although you would need to replace their second
factor with one of your own choosing, e.g. Cisco tokens or an SMS).

I have been thinking about building a reusable two-factor auth app for
Django which supports Google Authenticator [3] and ties in with
contrib.auth, which would let your phone act as the second factor
without requiring SMS.

[1] 
http://stackoverflow.com/questions/5096924/implementing-a-secure-two-factor-authentication-for-a-login-page-with-django-form

[2] https://github.com/duosecurity/duo_web/tree/master/demos/django

[3] http://www.google.com/support/a/bin/answer.py?answer=1037451



On Apr 27, 4:28 pm, "mendes.rich...@gmail.com" 
wrote:
> Dear Django developers,
>
> Recently we've been asked to start a medical project with the highest
> security level system and login wise.
> This means we have to work with a double login system either managed
> via cisco tokens or sms codes send
> to the owners phone.
>
> After some searching around i found the django sms module which can be
> used, but am wondering if someone else
> has experienced some projects like this and can give me some pointers
> in set-up, possible interesting modules and
> pitfalls to look out for.
>
> any help would be greatly appreciated,
>
> best regards,
>
> Richard Mendes

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

2011-04-28 Thread Tom Evans
On Thu, Apr 28, 2011 at 8:47 AM, Kenneth Gonsalves
 wrote:
> On Thu, 2011-04-28 at 00:27 -0700, Derek wrote:
>> A good IDE will convert tabs to spaces for you save you hours of
>> frustration!
>
> tab-nanny is also your friend

Or in vim:
:set expandtab shiftwidth=4 tabstop=4 | retab

Short form:
:se et sw=4 ts=4 | ret

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

2011-04-28 Thread Kenneth Gonsalves
On Thu, 2011-04-28 at 00:27 -0700, Derek wrote:
> A good IDE will convert tabs to spaces for you save you hours of
> frustration! 

tab-nanny is also your friend
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Extremely Frustrated

2011-04-28 Thread Derek
On Apr 25, 3:53 pm, Gandeida  wrote:
> Hello,
>
> I am running version 1.3.
>
> After copying and pasting about 20 more times, but getting the error
> sporadically, I have found that the issue was the tab characters that
> were being automatically generated to keep my indentation level.  I've
> changed it to use spaces instead.  Thank you for offering to help,
> though!  I just figured it out by accident :-)
>
> Regards,
> Gandeida

A good IDE will convert tabs to spaces for you save you hours of
frustration!

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



Re: Form redisplay in the case of form errors?

2011-04-28 Thread Derek
On Apr 26, 11:57 am, Daniel Roseman  wrote:
> On Tuesday, April 26, 2011 10:37:50 AM UTC+1, Derek wrote:
>
> > I have a form that I am expecting will redisplay with errors; it does not
> > do so.  Instead, the "print form.errors" statement is reached which does, in
> > fact, show that there are errors. For example:
>
> > cellphoneThis field is
> > required.
>
> > What else do I need to do to have the form be redisplayed?
>
> > Thanks
> > Derek
>
> > # form
> > class PersonForm(ModelForm):
> >     class Meta:
> >         model = Person
> >         fields = (
> >             'first_name', 'last_name', 'date_of_birth', 'gender', 'email',
> >             'cellphone', 'area',
> >             )
>
> > # view
> >     person = Person.objects.get(pk=id)
> >     if request.method == 'POST':
> >         form = PersonForm(request.POST, instance=person)
> >         if form.is_valid():
> >             form.save()
> >             return HttpResponseRedirect('/profile/')
> >         else:
> >             print form.errors
> >     else:
> >         form = PersonForm(instance=person)
> >         return render_to_response(
> >             'profile_edit.html',
> >             {'form': form},
> >             context_instance=RequestContext(request))
>
> Just move the final return call back one indent. The form will then be
> displayed in all cases other than successful validation.

Thanks Daniel for the hint.  For the record, this was the final code
that worked:

# Get person to be edited
person = Person.objects.get(pk=id)
# Create form
if request.method == 'POST':
form = PersonForm(request.POST, instance=person)
if form.is_valid():
# Save form data if valid
form.save()
return HttpResponseRedirect('/profile/')
else:
form = PersonForm(instance=person)
# Display form (also show any form errors)
return render_to_response(
'profile_edit.html',
{
'username': request.user.username,
'profile_info': user_profile,
'form': form
},
context_instance=RequestContext(request))

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