Re: How do I set permissions for manual install of 1.3 for ubuntu 11.04?

2011-04-29 Thread Shawn Milochik

What's the actual command you're typing, and from which directory?

--
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: please help

2011-04-29 Thread GKR
more  over how to use the admin django login system in my own created 
templates and views.
please help lil bit desciptively.

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



please help

2011-04-29 Thread GKR
for a particular project with login system which type u all suggest is the 
best.

1. login system to be create by self model
2. to use the login system provided by django

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



How do I set permissions for manual install of 1.3 for ubuntu 11.04?

2011-04-29 Thread jsierra
I installed django 1.3 manually on my laptop, since ubuntu 11.04 does not 
ship with 1.3 and I want to be able to run django-admin without having to 
sudo the command when creating projects and subsequently having to use sudo 
with manage.py. I want to mimic whatever permissions that allowed me to use 
the django-admin as a normal user, just like the ubuntu package does.

Here is the error i get with running django-admin without sudo:

Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in 
management.execute_from_command_line()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 429, in execute_from_command_line

  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 379, in execute

  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 191, in run_from_argv
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 220, in execute
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 322, in handle
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/startproject.py",
 
line 30, in handle_label
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 407, in copy_helper
IOError: [Errno 13] Permission denied: 
'/usr/local/lib/python2.7/dist-packages/django/conf/project_template/settings.py'


Regards,
Joshua Sierra

-- 
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: Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Shawn Milochik
It's always better to download the latest, and use virtualenv.

-- 
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 composition in Django

2011-04-29 Thread Ernesto Guevara
Thanks for the clarification, I put in the ForeignKey in employee class and is
working.
Regards!

2011/4/27 Tom Evans 

> On Sun, Apr 17, 2011 at 9:21 PM, W Craig Trader 
> wrote:
> > If your goal is to have an employee object that has direct access to all
> of
> > its related person object, and whose only new data field is a reference
> to
> > an address object, then you should change the Employee model to this:
> >
> > class Address(models.Model):
> >pass
> >
> > class Person(models.Model):
> >name = models.CharField(max_length=50)
> >date_inclusion = models.DateField()
> >
> > class Employee(models.Model):
> >person = models.OneToOneField(Person)
> >address = models.ForeignKey(Address)
> >
>
> Just to point out, this is MTI reinvented, without any of the Django
> syntactic magic sprinkled on top. It is exactly equivalent to this:
>
> class Address(models.Model):
>pass
>
> class Person(models.Model):
>name = models.CharField(max_length=50)
>date_inclusion = models.DateField()
>
> class Employee(Person):
>address = models.ForeignKey(Address)
>
> """
> The second type of model inheritance supported by Django is when each
> model in the hierarchy is a model all by itself. Each model
> corresponds to its own database table and can be queried and created
> individually. The inheritance relationship introduces links between
> the child model and each of its parents (via an automatically-created
> OneToOneField).
> """
>
>
> http://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance
>
> 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.
>
>

-- 
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: Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Ernesto Guevara
In the repository of ubuntu 10.04.2 the version 1.1.1 is available, better
download version 1.3 of the Django site and install. Is very easy.
Regards!


2011/4/29 Korobase 

> Does django 1.3 has a ubuntu deb package released !
> I have googled but get none,Any one have done 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-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: Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Yongning Liang
maybe there is no need to do this, you got python, and you can install
Django with simple python setup.py install

On Sat, Apr 30, 2011 at 10:29 AM, Korobase  wrote:

> Does django 1.3 has a ubuntu deb package released !
> I have googled but get none,Any one have done 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-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: django-admin.py startproject mysite

2011-04-29 Thread Yongning Liang
type this in Windows
python django-admin.py startproject mysite
if it doesn't work, make sure that both python and django-admin in you
system PATH

On Sat, Apr 30, 2011 at 5:38 AM, Daisy  wrote:

> Greetings all;
>
> I have a problem also with the "django-admin.py startproject mysite"
> command
>
> when i type it, it didn't create the directory mysite instead it opens
> the django-admin.py in a notepad++
>
> I don't know how to fix this?
> any ideas please.
>
> --
> 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.



Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Korobase
Does django 1.3 has a ubuntu deb package released !
I have googled but get none,Any one have done 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py startproject mysite

2011-04-29 Thread Daisy
Greetings all;

I have a problem also with the "django-admin.py startproject mysite"
command

when i type it, it didn't create the directory mysite instead it opens
the django-admin.py in a notepad++

I don't know how to fix this?
any ideas please.

-- 
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 on my iPod, LOL

2011-04-29 Thread Learning
http://www.flickr.com/photos/liangyongning/5670421250/in/photostream

Django on my iPod, LOL, see? localhost

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



Re: Multiple databases - unmanaged models - get_absolute_url()

2011-04-29 Thread David Chandek-Stark
I submitted a patch to the admin change form template -- 
http://code.djangoproject.com/ticket/15931.

Meanwhile, you can temporarily get around the problem on a per-application 
basis by adding the attached file to the application package directory 
at templates/admin//change_form.html.

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

{# Hack around Django bug http://code.djangoproject.com/ticket/15931 #}
{% extends "admin/change_form.html" %}
{% load i18n %}

{% block object-tools-items %}
  {% trans "History" %}
  {% if has_absolute_url %}{% trans "View on site" %}{% endif%}
{% endblock %}


Re: can't create test (secondary) database

2011-04-29 Thread Javier Guerra Giraldez
On Fri, Apr 29, 2011 at 1:16 PM, Shawn Milochik  wrote:
> This doesn't help if the same host is being used, but you can get around
> this by creating a second settings file and using it during your tests.

thanks, i forgot that option.

i'm using that to override the engine of the oracle database, turning
to SQLite during test.  unfortunately, since my legacy models have a
managed=False setting, they're not created in the test database.

for now, i added some preparation code that overrides that setting, to
ensure that all the tables are created for testing.  it's _very_ ugly,
but not much worse than some mocking code i've seen.

-- 
Javier

-- 
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: Custom template tag -- Not registered?

2011-04-29 Thread Kenny Meyer
On Fri, Apr 29, 2011 at 5:11 PM, Daniel Roseman  wrote:
> On Friday, 29 April 2011 21:24:44 UTC+1, Kenny Meyer wrote:
>>
>> Hello,
>>
>> I have the following inclusion tag in templatetags/show_submissions.py :
>>
>> ## BOF
>>
>> register = template.Library()
>>
>> @register.inclusion_tag('competition/templatetags/show_submissions.html')
>> def show_submissions(participant):
>>     submissions = Submission.objects.get(participant=participant)
>>     return {"submissions": submissions}
>>
>> ## EOF
>>
>> Whenever Django reaches the following line in my templates:
>>
>>     {% show_submissions user.participant %}
>>
>> A TemplateSyntaxError gets raised, which I interpret as "I don't find
>> your templatetag". Here's the full traceback:
>> http://dpaste.com/537298/
>>
>> Observations:
>> * Restarted the dev server several times after registering the tag,
>> and got the same results.
>> * templatetags/ folder has a __init__.py
>> * Using Django 1.3
>>
>> Any ideas why I cannot use this inclusion tag?
>>
>> Kenny
>
> Your template doesn't seem to have {% load show_submissions %} anywhere.

Oh, I really forgot that... there was indeed no {% load
show_submissions %} anywhere.

Thanks for your kind help!

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



Re: Custom template tag -- Not registered?

2011-04-29 Thread Daniel Roseman
On Friday, 29 April 2011 21:24:44 UTC+1, Kenny Meyer wrote:
>
> Hello,
>
> I have the following inclusion tag in templatetags/show_submissions.py :
>
> ## BOF
>
> register = template.Library()
>
> @register.inclusion_tag('competition/templatetags/show_submissions.html')
> def show_submissions(participant):
> submissions = Submission.objects.get(participant=participant)
> return {"submissions": submissions}
>
> ## EOF
>
> Whenever Django reaches the following line in my templates:
>
> {% show_submissions user.participant %}
>
> A TemplateSyntaxError gets raised, which I interpret as "I don't find
> your templatetag". Here's the full traceback:
> http://dpaste.com/537298/
>
> Observations:
> * Restarted the dev server several times after registering the tag,
> and got the same results.
> * templatetags/ folder has a __init__.py
> * Using Django 1.3
>
> Any ideas why I cannot use this inclusion tag?
>
> Kenny
>

Your template doesn't seem to have {% load show_submissions %} anywhere.
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multiple databases - unmanaged models - get_absolute_url()

2011-04-29 Thread David Chandek-Stark
OK, that's good.  However, I don't really understand why the admin site 
employs such an extremely convoluted method here.  If you follow the logic 
from the change form, here's what happens:

if has_absolute_url (i.e., the object model has a "get_absolute_url" 
attribute) ...
  -> display "view on site" link, which goes to ...
  -> view that looks up the content type object, then...
  -> gets the object of that type having the id passed in, then ...
  -> calls get_absolute_url() on the object, and ...
  -> redirects to that url

How is that ultimately different from:

if has_absolute_url 
  -> display "view on site" link with href="{{ obj.get_absolute_url }}"

(except that it appears the admin change form view doesn't pass the obj to 
the template context?!) ?

--David

On Friday, April 29, 2011 2:54:11 PM UTC-4, Ramiro Morales wrote:

> On Fri, Apr 29, 2011 at 2:18 PM, David Chandek-Stark
>  wrote:
>
> > [...]
> >  Now, I think the problem
> > is that this method uses the database for the contenttypes app instead of
> > the alternate database
> > (see 
> http://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/contenttypes/models.py#L102
> )
> > because it explicitly calls using() with the model state of the 
> ContentType
> > object.
> > Am I reading the Django code right, or am I doing something wrong?
>
> Coincidentally, someone else has atached a patch for ticket [1]15610 today.
>
> Any help with tests for the proposed fix is welcome.
>
> -- 
> Ramiro Morales
>
> 1. http://code.djangoproject.com/ticket/15610
>
>

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



Custom template tag -- Not registered?

2011-04-29 Thread Kenny Meyer
Hello,

I have the following inclusion tag in templatetags/show_submissions.py :

## BOF

register = template.Library()

@register.inclusion_tag('competition/templatetags/show_submissions.html')
def show_submissions(participant):
submissions = Submission.objects.get(participant=participant)
return {"submissions": submissions}

## EOF

Whenever Django reaches the following line in my templates:

{% show_submissions user.participant %}

A TemplateSyntaxError gets raised, which I interpret as "I don't find
your templatetag". Here's the full traceback:
http://dpaste.com/537298/

Observations:
* Restarted the dev server several times after registering the tag,
and got the same results.
* templatetags/ folder has a __init__.py
* Using Django 1.3

Any ideas why I cannot use this inclusion tag?

Kenny

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jeff Blaine
Thank you both.  That's a great explanation, Jacob.  I'll consider your 
message more closely and play around on Monday a bit.

PS: I said it *seems* broken to me, as in "Maybe I just don't understand the 
reason.", which I clearly didn't :)

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



Re: Best way to tell if we're in a test

2011-04-29 Thread Jody McIntyre
This is fine as a general principle, but here we're dealing with middleware
that affects every other application.  It's not a good idea to require other
applications to change all their tests to mock out functionality in a module
they've just added, plus that would be a lot of work.  You'd have to use it
every time you run self.client.login() or post to the login URL in a test
case.  That's probably why django-digest and django-bcrypt disable
themselves under test (by default) and why I'd like to do it for security
questions.

Cheers,
Jody

On Fri, Apr 29, 2011 at 2:03 PM, Chris Czub  wrote:

> I think you might be taking the wrong approach. Rather than having your
> application code checking whether or not it's in a test, have your testing
> code disable/mock certain behaviors that you don't want exercised(like have
> it always return that the user answered the security question correctly or
> something).
>
> Python's dynamic nature makes it easy to monkey patch things like this.
> Look at the Mock class: http://python-mock.sourceforge.net/
>
>
> On Fri, Apr 29, 2011 at 12:53 PM, Jody McIntyre wrote:
>
>> What's the best way to tell (from regular code) if we're in a test?  I
>> have added extra authentication steps (security questions) that would be
>> difficult to deal with in tests where you just want to run
>> self.client.login() or post to the login URL.  I've noticed that several
>> third party modules, such as django-digest and django-bcrypt, also disable
>> parts of their functionality during testing like this:
>>
>> from django.core import mail
>>
>> if hasattr(mail, 'outbox'):
>> # we are under a test
>> else:
>> # not under a test
>>
>> This works, but it's an undocumented side effect so I'm worried it might
>> change in a future version.  What's the correct way to tell if we're in a
>> test?
>>
>> Thanks,
>> Jody
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Cannot operate on a closed database

2011-04-29 Thread Thomas Weholt
I'm trying to run a unittest, but it crashes with an exception, saying
"Cannot operate on a closed dabase". I'm not using the orm to insert
records, but raw SQL - and raw sql is the only option. When or what
closes the connection to the database?

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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: Multiple databases - unmanaged models - get_absolute_url()

2011-04-29 Thread Ramiro Morales
On Fri, Apr 29, 2011 at 2:18 PM, David Chandek-Stark
 wrote:

> [...]
>  Now, I think the problem
> is that this method uses the database for the contenttypes app instead of
> the alternate database
> (see http://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/contenttypes/models.py#L102)
> because it explicitly calls using() with the model state of the ContentType
> object.
> Am I reading the Django code right, or am I doing something wrong?

Coincidentally, someone else has atached a patch for ticket [1]15610 today.

Any help with tests for the proposed fix is welcome.

-- 
Ramiro Morales

1. http://code.djangoproject.com/ticket/15610

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



Re: can't create test (secondary) database

2011-04-29 Thread Shawn Milochik
You can specify the test database info (db, name, and password) for each 
database defined in settings, if you're using 1.2 or greater.


http://docs.djangoproject.com/en/1.3/ref/settings/#databases

This doesn't help if the same host is being used, but you can get around 
this by creating a second settings file and using it during your tests.


In your second settings file, (let's call it test_settings.py), you 
would only import the main settings and then override what you have to.


from settings import *

DATABASES['your_oracle_db'] = {'host': 'new_host', 'port': 1234}

Then run your tests by passing --settings=test_settings instead of using 
the default.


Be careful not to change too much in your alternate settings file or you 
run the risk of testing something too different than your real setup and 
missing a flaw.


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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



can't create test (secondary) database

2011-04-29 Thread Javier Guerra Giraldez
Hi All,

for the first time, i'm using multiple databases.  specifically, i
have 'my' data in a MySQL db (set as 'default') but also need to get
some extra info from a proprietary system with it's own Oracle DB, for
this i got a user/password with read/only privileges (only SELECT and
friends).  Of course, when i want to run the tests, i get an "error
creating the test database: ORA-01031: insufficient privileges"
message.

i guess any of these (in decreasing order of preference) would be a
solution, but i don't know how to do any of them.  (well, maybe the
last one could be done via some creative use of
development/test/deployment patching)

1: use the 'real' db.  since the user is read/only, i can't mess it
up.  i can't install test fixtures either, but there's lots of old
records that are static enough for my tests.

2: create both test DBs in the MySQL server.  of course, the SQL
semantics aren't the same; but i'm using _very_ simple queries to get
that foreign data.

3: create the test DB in another oracle server.  i guess that's the
simplest advice, but also the one i hope to avoid.

any advices?


-- 
Javier

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



Re: Best way to tell if we're in a test

2011-04-29 Thread Chris Czub
I think you might be taking the wrong approach. Rather than having your
application code checking whether or not it's in a test, have your testing
code disable/mock certain behaviors that you don't want exercised(like have
it always return that the user answered the security question correctly or
something).

Python's dynamic nature makes it easy to monkey patch things like this. Look
at the Mock class: http://python-mock.sourceforge.net/

On Fri, Apr 29, 2011 at 12:53 PM, Jody McIntyre wrote:

> What's the best way to tell (from regular code) if we're in a test?  I have
> added extra authentication steps (security questions) that would be
> difficult to deal with in tests where you just want to run
> self.client.login() or post to the login URL.  I've noticed that several
> third party modules, such as django-digest and django-bcrypt, also disable
> parts of their functionality during testing like this:
>
> from django.core import mail
>
> if hasattr(mail, 'outbox'):
> # we are under a test
> else:
> # not under a test
>
> This works, but it's an undocumented side effect so I'm worried it might
> change in a future version.  What's the correct way to tell if we're in a
> test?
>
> Thanks,
> Jody
>
> --
> 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.



Best way to tell if we're in a test

2011-04-29 Thread Jody McIntyre
What's the best way to tell (from regular code) if we're in a test?  I have 
added extra authentication steps (security questions) that would be 
difficult to deal with in tests where you just want to run 
self.client.login() or post to the login URL.  I've noticed that several 
third party modules, such as django-digest and django-bcrypt, also disable 
parts of their functionality during testing like this:

from django.core import mail

if hasattr(mail, 'outbox'):
# we are under a test
else:
# not under a test

This works, but it's an undocumented side effect so I'm worried it might 
change in a future version.  What's the correct way to tell if we're in a 
test?

Thanks,
Jody

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jacob Kaplan-Moss
On Fri, Apr 29, 2011 at 12:17 PM, Jeff Blaine  wrote:
> "primary_key=True implies null=False and unique=True. Only one primary key
> is allowed on an object."
> So that unique=True part is inaccurate?  Or is that, again, another thing
> that will fail only at validation?

Maybe this'll help::

# Log every SQL query
>>> import logging
>>> l = logging.getLogger('django.db.backends')
>>> l.setLevel(logging.DEBUG)
>>> l.addHandler(logging.StreamHandler())

# Now let's play...
>>> from myapp.models import Device
>>> d1 = Device()
>>> d1.save()
(0.002) SELECT (1) AS "a" FROM "cfpk_device" WHERE
"cfpk_device"."propertyno" = E''  LIMIT 1; args=('',)
(0.001) INSERT INTO "cfpk_device" ("propertyno") VALUES (E''); args=('',)

>>> d2 = Device()
>>> d2.save()
(0.001) SELECT (1) AS "a" FROM "cfpk_device" WHERE
"cfpk_device"."propertyno" = E''  LIMIT 1; args=('',)

You have to remember that `object.save()` could mean INSERT *or*
UPDATE depending on whether the object with the given primary key
exists or not. When you create a new device, because again the default
is the empty string, you've already got one of those in the DB. Django
notices that it doesn't need updating, and so it doesn't update it.

Now consider this:

>>> d2.save()
(0.001) INSERT INTO "cfpk_device" ("propertyno") VALUES (E''); args=('',)
Traceback (most recent call last):
...
IntegrityError: duplicate key value violates unique constraint
"cfpk_device_pkey"
DETAIL:  Key (propertyno)=() already exists.

If you force an insert, you'll see the error you're expecting.

I'm sorry if you think it's broken. I disagree, though: Django's
working the way we designed it to work. You've exposed a subtle
edge-case (which shows just one reason why I use surrogate keys almost
without exception).

Jacob

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Javier Guerra Giraldez
On Fri, Apr 29, 2011 at 12:17 PM, Jeff Blaine  wrote:
> "primary_key=True implies null=False and unique=True. Only one primary key
> is allowed on an object."
> So that unique=True part is inaccurate?  Or is that, again, another thing
> that will fail only at validation?

did you test pass more than once?

check the saved object(s?), is the primary key field a zero string, or
NULL?  most databases consider NULL non-equal to any value, including
other NULLs, and allow multiple records with NULLs in a unique field.

also, some databases consider the zero string a valid representation
for NULL.  which RDBMS are you using?

-- 
Javier

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



Multiple databases - unmanaged models - get_absolute_url()

2011-04-29 Thread David Chandek-Stark
No doubt this is an edge case, but here goes ...

With Django 1.3/Python 2.4 I have an app consisting of *unmanaged *models in 
*alternate *(non-default) database.  Each model has defined 
get_absolute_url() simply as a fully-qualified (i.e.,external) URL string in 
which the instance id is substituted.   Everything seems to work fine, 
except the "View on site" link on the object change pages, which raises a 
DatabaseError (no such table exists) exception.  The link resolves to the 
view django.contrib.contenttypes.views.shortcut, which gets the ContentType 
instance for the object, then re-retrieves the original object (!?) using 
the ContentType.get_object_for_this_type() method.  Now, I think the problem 
is that this method uses the database for the contenttypes app instead of 
the alternate database 
(see 
http://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/contenttypes/models.py#L102)
 
because it explicitly calls using() with the model state of the ContentType 
object.

Am I reading the Django code right, or am I doing something wrong?

Thanks,
David

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



Re: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jeff Blaine
"primary_key=True implies 
null=False
 and 
unique=True.
 
Only one primary key is allowed on an object."

So that unique=True part is inaccurate?  Or is that, again, another thing 
that will fail only at validation?

This seems pretty broken to me :(

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



Re: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jacob Kaplan-Moss
On Fri, Apr 29, 2011 at 11:47 AM, Jeff Blaine  wrote:
> How is this possible based on the model below?
> d = Device()
> d.save()
> # no errors
> class Device(models.Model):
>     propertyno      = models.CharField('Property Number',
>                                        max_length=10,
>                                        primary_key=True)

It's because CharField have a `default` of "" -- that is, the empty
string. So you've created a Device with a propertyno of "" (again, an
empty string). That's a valid pk value as far as some DBs are
concerned.

Notice that the model won't validate -- because you haven't set
`blank` to `True` -- but it will save. (For backwards-compatibility
reasons, save() can't trigger validation).

Jacob

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jeff Blaine
A specified primary_key should not be auto-incrementing from my 
understanding.  The following shows 2 objects with the same value for a 
field I specified should be the primary_key:

>>> from hostdb.models import Device
>>> d = Device()
>>> d.propertyno
''
>>> d.save()
>>> d = Device()
>>> d.propertyno
''
>>> d.save()
>>>

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jeff Blaine
"If Django sees you've explicitly set 
Field.primary_key,
 
it won't add the automatic id column."

http://docs.djangoproject.com/en/1.3/topics/db/models/#automatic-primary-key-fields

-- 
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: .save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Cal Leeming [Simplicity Media Ltd]
I think because the primary_key field auto defaults to be auto-inc?

On Fri, Apr 29, 2011 at 5:47 PM, Jeff Blaine  wrote:

> How is this possible based on the model below?
>
> d = Device()
> d.save()
> # no errors
>
> class Device(models.Model):
>
> propertyno  = models.CharField('Property Number',
>max_length=10,
>primary_key=True)
>
>  --
> 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.



.save() works with no (custom, not 'id') primary key specified?

2011-04-29 Thread Jeff Blaine
How is this possible based on the model below?

d = Device()
d.save()
# no errors

class Device(models.Model):

propertyno  = models.CharField('Property Number',
   max_length=10,
   primary_key=True)

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



Template syntax erro

2011-04-29 Thread Elton Pereira
When trying to upload or download files that contain non-ascii
caracters raise a TemplateSyntaxError exception with the following
contents:

Django Version: 1.2.5
Exception Type: TemplateSyntaxError
Exception Value:

Caught UnicodeEncodeError while rendering: 'ascii' codec can't encode
characters in position 125-126: ordinal not in range(128)

Exception Location: /usr/local/lib/python2.6/dist-packages/django/
core/files/storage.py in _open, line 137
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:['/home/protocolo/protocolo', '/home/protocolo', '/home/
protocolo/protocolo', '/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/pymodules/python2.6', '/usr/local/lib/python2.6/dist-
packages', '/usr/lib/openoffice/basis-link/program']
Server time:Sex, 29 Abr 2011 11:56:10 -0300

I have done what is on this page but not solved:
http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

Thanks!

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



Re: django-cas-consumer template question

2011-04-29 Thread Stodge
Of course! Thanks - I have the template working, now I need to get the
login functionality working for the consumer.



On Apr 29, 9:35 am, Alex Kamedov  wrote:
> Your user must be redirected from django-cas-consumer login view to
> django-cas-provider
> login. Login form is shown on service with django-cas-provider.
>
> On Fri, Apr 29, 2011 at 7:30 PM, Stodge  wrote:
> > django-cas-consumer
>
> --
> Alex Kamedov
> skype: kamedov    www: 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.



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

2011-04-29 Thread Margie Roginski
Hi Karen,

Ah, very sorry - my mistake!  The machine I was using had an old
version of python and it was using django 1.0.  So that's why it
didn't create tests.py, and I just assumed there must be a bunch of
changes between 1.1 and 1.2.

Ok, mystery solved.  Thanks for your explanation of the differences, I
will look out for those.  I'm sure I'll learn a lot from your book.
I've just completed a large django project and am moving onto my first
real position in web application development (using django of course)
at a new company.  Previously I was in a different field of software
and created a django product to bootstrap myself on web app
development there.   The one thing I feel that I could have done
better on my recent project was my testing.  I used selenium
extensively (and that did work well for me), but I did not test from
inside the core django framework much, so I am looking forward to
learning from your book.

Thanks!

Margie

On Apr 29, 4:40 am, Karen Tracey  wrote:
> On Thu, Apr 28, 2011 at 6:18 PM, Margie Roginski
> wrote:
>
>
>
> > 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!
>
> No, the sample tests.py file is still created in by startapp in Django 1.2,
> 1.3, and current trunk code. That hasn't changed since it was added (we were
> remarking at the office a week or so ago that Django devs are going to be
> the first to know if and when 1+1 no longer equals 2). What exactly led you
> to the conclusion that tests.py is no longer created by 1.2?
>
> Going forward to 1.3, there is a difference in the tests.py file created:
> the sample tests file no longer contains a doctest in 1.3. For Django's own
> test suite there was a big push during the 1.3 cycle to rewrite all doctests
> as unit tests, and although doctests in apps are still fully supported,
> there's a general consensus among the core team that unit tests are a better
> tool, so the sample doctest was removed in 1.3 in order to encourage users
> also more towards unit tests than doctests. But as I said doctests are still
> supported for apps, so all the sample doctests in the book can still be
> tried even in more recent Django versions.
>
> > In some quick review of the 1.2 doc, it seems like perhaps there are
> > other changes as well.
>
> The biggest change in testing between 1.1 and 1.2 was that 1.2 introduced a
> new feature to allow easier creation of custom test runners. In the part of
> the book that discusses this topic, that is mentioned.
>
> There are bigger changes with 1.3, with the introduction of unittest2. But
> the fundamentals of testing that the book attempts to convey are still the
> same, it just won't be able to point out some of the newer features that are
> now available.
>
> There is no update of the book (nor anything planned). It was written during
> the 1.2 development cycle. The last chance I had to make any changes to the
> text was when 1.2 was in late beta, and that is when I did add notes about
> things that had definitely changed between 1.1 and 1.2 (like the custom test
> runner stuff).
>
> Karen
> --http://tracey.org/kmt/

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



Re: django-cas-consumer template question

2011-04-29 Thread Alex Kamedov
Your user must be redirected from django-cas-consumer login view to
django-cas-provider
login. Login form is shown on service with django-cas-provider.

On Fri, Apr 29, 2011 at 7:30 PM, Stodge  wrote:

> django-cas-consumer




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



django-cas-consumer template question

2011-04-29 Thread Stodge
I installed django-cas-provider and django-cas-consumer. I configured
the consumer to use the CAS service offered by the provider and I
added a base.html template for the consumer. Is this base template
supposed to contain the login form? Or is the login form supposed to
be available on teh provider? The documentation doesn't mention the
login form at all.

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.



user and perms context variables from auth context processor (in Django 1.2.3)

2011-04-29 Thread simon
Hello,

I am using Django 1.2.3. I was trying to check user permissions on a
certain model using the perms context variable from
contrib.auth.context_processors.auth. As per the documentation, I
tried this (foo is the app label, Bar is the model, and I'm using
default permissions):

{% if perms.foo.change_bar %} do stuff {% endif %}

It's always false even when logged in as a superuser. I tried doing
{{user.username}} to see if the user variable worked and it also
displayed nothing. So I checked in the debug toolbar and the variables
I get from the auth context processor are these:

{'messages':
,
 'perms': ,
 'user': }

My questions are:
1) wasn't the SimpleLazyObject for user not fixed as claimed by ticket
12060 ( http://code.djangoproject.com/ticket/12060 ) ? Or was it fixed
after 1.2.3?
2) How do I go about checking permissions using the perms variable? It
seemed to be wrapped in some other function.

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-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: Question about "Django 1.1 Testing and Debugging" Book for Karen

2011-04-29 Thread Karen Tracey
On Thu, Apr 28, 2011 at 6:18 PM, Margie Roginski
wrote:

>
> 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!
>
>
No, the sample tests.py file is still created in by startapp in Django 1.2,
1.3, and current trunk code. That hasn't changed since it was added (we were
remarking at the office a week or so ago that Django devs are going to be
the first to know if and when 1+1 no longer equals 2). What exactly led you
to the conclusion that tests.py is no longer created by 1.2?

Going forward to 1.3, there is a difference in the tests.py file created:
the sample tests file no longer contains a doctest in 1.3. For Django's own
test suite there was a big push during the 1.3 cycle to rewrite all doctests
as unit tests, and although doctests in apps are still fully supported,
there's a general consensus among the core team that unit tests are a better
tool, so the sample doctest was removed in 1.3 in order to encourage users
also more towards unit tests than doctests. But as I said doctests are still
supported for apps, so all the sample doctests in the book can still be
tried even in more recent Django versions.


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


The biggest change in testing between 1.1 and 1.2 was that 1.2 introduced a
new feature to allow easier creation of custom test runners. In the part of
the book that discusses this topic, that is mentioned.

There are bigger changes with 1.3, with the introduction of unittest2. But
the fundamentals of testing that the book attempts to convey are still the
same, it just won't be able to point out some of the newer features that are
now available.

There is no update of the book (nor anything planned). It was written during
the 1.2 development cycle. The last chance I had to make any changes to the
text was when 1.2 was in late beta, and that is when I did add notes about
things that had definitely changed between 1.1 and 1.2 (like the custom test
runner stuff).

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

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



Re: sorting model data in template page

2011-04-29 Thread Victor Harada
The for tag does not accept calls with parameter.

You should make the view function calculate the sorted list and pass it to
the template or create a template tag that accepts your call

2011/4/29 Krish 

> This code works perfectly,
>
> {% for talk_child in talk.child.all %}
> {{talk_child.text}} {{talk_child.created_dt}}
> {% endfor %}
>
> Now, I want to sort all child based on created_dt ASC (something like
> below), but it doesn't work. How can I get this right?
>
> {% for talk_child in talk.child.order_by 'created_dt' %}
> {{talk_child.text}} {{talk_child.created_dt}}
> {% endfor %}
>
> Below is my class
> class Talk(models.Model):
>user = models.ForeignKey(User)
>destination = models.ForeignKey(Destination)
>text = models.TextField()
>type = models.CharField(max_length=30)
>sup = models.ForeignKey('self', blank=True, null=True,
> related_name='child')
>created_dt = models.DateTimeField(auto_now_add=True)
>thumb_up = models.IntegerField()
>thumb_down = models.IntegerField()
>
> class Meta:
>ordering = ["-created_dt"]
>
> --
> 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: This section is converting database table to excel file

2011-04-29 Thread Od-Erdene Ch
thank you very much for your advice, but unfortunately this method taking
more than 10 minutes too.
if there's a any better way please.

response = HttpResponse(result.read(),
mimetype='application/ms-excel')

response['Content-Disposition'] = 'attachment;
filename=Car_details_%s.xls' % today

||

\/

response = HttpResponse(result.read(), mimetype='text/csv')

response['Content-Disposition'] = 'attachment;
filename=Car_details_%s.csv' % today




2011/4/28 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 

sorting model data in template page

2011-04-29 Thread Krish
This code works perfectly,

{% for talk_child in talk.child.all %}
{{talk_child.text}} {{talk_child.created_dt}}
{% endfor %}

Now, I want to sort all child based on created_dt ASC (something like
below), but it doesn't work. How can I get this right?

{% for talk_child in talk.child.order_by 'created_dt' %}
{{talk_child.text}} {{talk_child.created_dt}}
{% endfor %}

Below is my class
class Talk(models.Model):
user = models.ForeignKey(User)
destination = models.ForeignKey(Destination)
text = models.TextField()
type = models.CharField(max_length=30)
sup = models.ForeignKey('self', blank=True, null=True,
related_name='child')
created_dt = models.DateTimeField(auto_now_add=True)
thumb_up = models.IntegerField()
thumb_down = models.IntegerField()

class Meta:
ordering = ["-created_dt"]

-- 
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 configure mongoDB in Django?

2011-04-29 Thread Kenneth Gonsalves
On Fri, 2011-04-29 at 00:52 -0700, ashish tiwari wrote:
> i used Django with Sqlite3,
> I'm thinking about to use MongoDB as backend.
> but i don't no how to configure it,
> and which packages need to configure mongoDB in Django? 

as of now django does not support nosql. In fact there is a hot
discussion going on among some of the developers on this topic. There
are some forks that support some or all the nosql stores, but you will
have to actually try them out.
-- 
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: cx_Oracle error: ImproperlyConfigured

2011-04-29 Thread Jirka Vejrazka
Have you checked permissions?

-- 
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 configure mongoDB in Django?

2011-04-29 Thread ashish tiwari
Hey friends,
i used Django with Sqlite3,
I'm thinking about to use MongoDB as backend.
but i don't no how to configure it,
and which packages need to configure mongoDB in Django?

Best Regards
--ashish

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