FORMS help needed

2007-09-06 Thread AniNair

Hi..
   I am using django 0.97 pre with python 2.5.1. I have been trying to
learn this but i am having trouble with forms. What I want is to
submit data in one page and do calculations with it and return the
result in other page. I managed to do it using cgi, but can anyone
tell me how to get data in django? I should I use get_list_or_404()? I
have my url conf as

from django.conf.urls.defaults import *
from dbp.users.views import show, get_id, showall

urlpatterns = patterns('',
(r'^users/', showall),(r'^showuser/([A-Za-z]+)', show),
)

The url on submitting is http://localhost:8000/showuser/?id_user=Ani
I get a page not found error saying
The current URL, showuser/, didn't match.
please advice. Thanking you in advance


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How run a python script as standalone? (aka: Why django need the DJANGO_SETTINGS_MODULE anyway???)

2007-09-06 Thread Daybreaker

I've made a standalone program that uses Django modules.

At settings.py:
import os
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))

At standalone script:
import sys, os
try:
import settings # this file was in the same directory of
settings.py
sys.path.append(os.path.join(settings.PROJECT_PATH, '..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'project_name.settings'
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
# .. import other necessary modules
except ImportError:
sys.stderr.write('Error: Cannot initialize environment.\n')
sys.exit(1)

After this code, I could import and use Django modules and my custom
models as in the views.

On Sep 6, 6:35 am, mamcxyz <[EMAIL PROTECTED]> wrote:
> I wanna debug inside a IDE (komodo 4) my test cases for django, so I'm
> looking for a way to simply run the script from the IDE and step in as
> usual.
>
> This is my layout:
>
> F:\Proyectos\Python\jhonWeb <= root inside it:
>
> \demo\ THE SITE with the settings file
> \shared\ shared models I have develop to share across several projects
> as blog, tags and users
>
> Inside \shared\ have:
>
> \articles\tests.py
>
> I try this:
>
> import sys
> import os
>
> project_dir = os.path.abspath('../../') # Go to F:\Proyectos\Python
> \jhonWeb
> sys.path.append(project_dir) # Add the root to the path and
> sys.path.append(project_dir+r'\\demo') #add the test project
> os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'
>
> But I have:
>
> "D:\Programacion\Python\Python24\lib\site-packages\django\db\models
> \base.py", line 52, in __new__
> new_class._meta.app_label = model_module.__name__.split('.')[-2]
> IndexError: list index out of range
>
> Obviously the thing work as usual if run it from python manage.py test
> and similars.
>
> Also, why is necesary the DJANGO_SETTINGS_MODULE magic after all???
>
> NOTE: Current trunk revision 6050.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to implement 3X2 lines?

2007-09-06 Thread [EMAIL PROTECTED]

you code is good.

i find another one but not work for me(forget author name, sorry):

"""
Template tags for working with lists.

You'll use these in templates thusly::

{% load listutil %}
{% for sublist in mylist|parition:"3" %}
{% for item in mylist %}
do something with {{ item }}
{% endfor %}
{% endfor %}
"""

from django import template

register = template.Library()

@register.filter
def partition(thelist, n):
"""
Break a list into ``n`` pieces. The last list may be larger than
the rest if
the list doesn't break cleanly. That is::

>>> l = range(10)

>>> partition(l, 2)
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]

>>> partition(l, 3)
[[0, 1, 2], [3, 4, 5], [6, 7, 8, 9]]

>>> partition(l, 4)
[[0, 1], [2, 3], [4, 5], [6, 7, 8, 9]]

>>> partition(l, 5)
[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]

"""
try:
n = int(n)
thelist = list(thelist)
except (ValueError, TypeError):
return [thelist]
p = len(thelist) / n
return [thelist[p*i:p*(i+1)] for i in range(n - 1)] + [thelist[p*(i
+1):]]

@register.filter
def partition_horizontal(thelist, n):
"""
Break a list into ``n`` peices, but "horizontally." That is,
``partition_horizontal(range(10), 3)`` gives::

[[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9],
 [10]]

Clear as mud?
"""
try:
n = int(n)
thelist = list(thelist)
except (ValueError, TypeError):
return [thelist]
newlists = [list() for i in range(n)]
for i, val in enumerate(thelist):
newlists[i%n].append(val)
return newlists

On 9月6日, 下午11时01分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I wrote this tag a couple months ago that should be of some 
> help.http://www.djangosnippets.org/snippets/296/
> You can at least use it as a starting point for your own tag.
>
> On Sep 6, 8:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > need your help, thx
>
> > On 9月6日, 下午3时21分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:> sorry, i 
> > am a newbie to python.
> > > i have a queryset with 6 record, i want to show in 3 col and 2 row,
> > > how to do this, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Translating strings with placeholder in template

2007-09-06 Thread Charles Chan

This works like a charm. Thank you very much.

Thanks,
Charles


On Sep 6, 2:58 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> > I think this would work with Python code. However, can I do the
> > translation in Django's Template language? If so, how?
>
> See 
> blocktrans:http://www.djangoproject.com/documentation/i18n/#in-template-code
>
> In short, you would use:
> {% blocktrans %}login.before.you.proceed {{ login_url }}{%
> endblocktrans %}
>
> The .po file would be exactly what you have above:
> msgid "login.before.you.proceed %(login_url)s"
> msgstr "Please Login before you proceed"


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form field deletion

2007-09-06 Thread Russell Keith-Magee

On 9/7/07, Oleg Korsak <[EMAIL PROTECTED]> wrote:

> I just want to create form_for_model and/or form_for_instance  and then
> delete one field (user). Is it possible or do I need to manually create my
> own form?

Sure - use the 'fields' option to specify the subset of model fields
you want to use on the form.

> Also when retrieving a form data from request.POST.copy() - can I
> (how?) update just some fields in existing record. Actually the goal is to
> not show this ForeignKey (user) field and not to update it too. Thanks

>>> Form = form_for_instance(instance, fields=('field1','field2'))
>>> f = Form(request.POST)
>>> f.save()

will update 'field1' and 'field2' on instance, but leave all other
fields unmodified.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: forms, views and foreign key

2007-09-06 Thread Oleg Korsak
oh sorry. I've fixed that. That is because of form_for_model. Now I'm using
form_for_instance and all is working well ;) thanks

2007/9/6, RajeshD <[EMAIL PROTECTED]>:
>
>
> > --
> > so.. the problem is:
> >
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/profile/
> > Exception Type: AttributeError
> > Exception Value:'Profile' object has no attribute 'get'
> >
> > what's wrong? :(
> >
>
> What line of code are you getting this error on? Can you paste the
> stack trace as well?
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Fixtures auto-incrementing primary keys?

2007-09-06 Thread Russell Keith-Magee

On 9/7/07, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
>
> Can fixtures have auto-incrementing primary keys or must you have
> specific PKs in the the serialized json/xml/etc files? If not, is
> there a reason for this?

This idea has occurred to me before, and I can see how it could be
useful, but I got caught up on one significant detail: how do you
handle references? When you specify the PK, you provide an identifier
to use as a cross reference. If this identifier no longer exists, what
do you use as a reference in its place?

> I'm programmatically generating fixtures from Freebase.org queries for
> a project. Although it's not a much extra work to add a pk counter, it
> is the second time this has struck me as annoying. Would the devs be
> open to a patch for this sort of thing?

You shouldn't even need to write a PK counter - just save the objects
without a primary key, and the database will allocate the next
available key. The issue is how to cross reference.

However, I am very much open to the general idea, as long as you can
provide a solution to the problem - and a patch would be even more
welcome.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



choices/ and getting rid of the dashes?

2007-09-06 Thread Mark Green

Hi all,

This is my model:

class Person(models.Model):
GENDER_CHOICES = (
( 'm', 'Male' ),
( 'f', 'Female' ),
)
gender = models.CharField( blank=False, "gender", maxlength=1, 
choices=GENDER_CHOICES, default='m' )



Using form_for_model() on the above model results in HTML like this:


-
Male
Female



How do I get rid of the first option (the dashes)?
I would prefer to have the -widget default to my default-value.

Any help appreciated!


-mark


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Storing Lookup Data

2007-09-06 Thread Lee Hinde

On Sep 6, 1:48 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> > It seems like the Choice table is easier on the user.  You tell them
> > to go to the Choices table to enter all the look-up data, as opposed
> > to giving them X tables to wade through.
>
> As you said, it is probably a DB design question -- even within a
> single project, you might need to use both approaches.
>
> My $.02:
>
> If you need special validation based on the type of the lookup data,
> the separate tables option works better. You can still make them go to
> one screen to manage all the lookup data (you're just going to have to
> build that screen yourself ;)
>
> Also, if you want foreign key relations to the choice data, separate
> tables might work better.
>
> I would personally never mix person name prefix data with a list of
> states in the same table even if you have a "type" field to qualify
> such data. To me, that kind of user convenience is not worth the loss
> in data integrity because one can always unify those lookups in a user-
> friendly UI.

Thanks. That all makes sense.



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



Re: Fixtures auto-incrementing primary keys?

2007-09-06 Thread [EMAIL PROTECTED]

On Sep 6, 10:55 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> Can fixtures have auto-incrementing primary keys or must you have
> specific PKs in the the serialized json/xml/etc files? If not, is
> there a reason for this?
>
> I'm programmatically generating fixtures from Freebase.org queries for
> a project. Although it's not a much extra work to add a pk counter, it
> is the second time this has struck me as annoying. Would the devs be
> open to a patch for this sort of thing?

Are you using PostgreSQL? If so you probably need to

select setval('sequence_name', x);

where x is the value of the last generated id

See pg's docs on this

http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html

Lorenzo


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Databases, one or many

2007-09-06 Thread James Bennett

On 9/6/07, Adam Jenkins <[EMAIL PROTECTED]> wrote:
> This actually brings up an issue. I've heard that many Django developers
> don't
> use projects at all, that they just use apps. Is this correct? Should I
> default to one
> project and break it up into smaller ones if the need arises?

First off, be very careful about how you use the terms; you cannot use
Django on the Web without a "project".

A "project", in its absolute bare minimum form, is a settings module
and a root URLConf module; applications *cannot* supply these things,
and without them Django cannot be used to serve anything.

An application supplies models, optionally some views, template tags, etc.

The question, then, is not "do I use a project?", because you *must*
have a project in order to have settings and a root URLConf.

Where people's opinions vary is on how to organize the applications
used within the project -- the things listed in the project's
INSTALLED_APPS setting. The question, in a nutshell, is whether the
applications should be developed inside the project's directory (and
hence be forever coupled to it), or be developed as standalone Python
modules in their own right (and hence can be used in multiple projects
simultaneously, or distributed independently of the project(s) which
originally used them).

The Django tutorial shows how to build an application which lives
completely within the project's directory, and hence is absolutely
coupled to the project (unless you fiddle with your Python import
path, the only way to access code in the application is to include the
project's name in the import statement). This is fine for a quick
"getting started"-style document like the tutorial, where explaining
anything else would complicate things unnecessarily, but for any sort
of production application it should be avoided.

The alternative is to develop applications as normal Python modules
which live on your Python import path, and to treat the project simply
as a bit of "glue" which binds them all together with appropriate
settings. This is vastly preferable because it means these
applications can be re-used independently of the project. Perhaps some
folks can swear that the code in their apps will never be re-used by
anyone at any point for the rest of eternity, but I can't and so I
don't couple my applications to specific projects.

As for your question about databases:

Django currently only supports using one database at a time, as
evidenced by the fact that the settings file only lets you specify one
database. My advice to you would be to replace the existing segregated
applications one at a time with Django applications -- you can create
separate "projects", each using one or two of the applications -- and
then, once you're ready to consolidate, use Django's 'manage.py
dumpdata' command to serialize all that data out, create one project
with one database which will use all the apps, and use 'manage.py
loaddata' to pull all that data into it.


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

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



Re: Django + PAM (Unix)

2007-09-06 Thread Mario Gonzalez

On 7 ago, 16:11, Mario Gonzalez <[EMAIL PROTECTED]> wrote:
>  Hello, I'm doing some tests in a module I found: libpam-pgsql,
> basically with that library you're able to authenticate accounts in a
> postgres table. All my web systems are powered byDjangoandDjango
> uses SHA1 as the main encryption algorithm; however libpam-pgsql not
> supported it and I'm trying to write some code for that.
>

  Hello again:

  I modified the libpam-pgsql to support Django. I'm using it in my
machine for testing purposes and I haven't found any problem so far.
Maybe some people (hackers?) could help with this. In short, I added
the support for SHA1 to libpam-pgsql and format the string password as
sha1$salt$password_in_sha1

  You cannot be able to change the password yet but I'm working on it.
Please, don't hesitate to write me back for any suggestions.

case PW_SHA1: {
/* The salt is the FULL PASSWORD:
sha1$12345$1234567890123456789012345678901234567890 */
char *buf;
int i, j;
MHASH handle;
unsigned char *hash;
char *token, *raw_password, *django_salt, 
*django_password, *salt;
unsigned short int django_password_size = 50;

handle = mhash_init(MHASH_SHA1);
if(handle == MHASH_FAILED) {
SYSLOG("could not initialize mhash library!");
} else {
salt = (char *)malloc(strlen(stored_pw));
strcpy(salt, stored_pw);
django_salt = get_django_salt(salt);
token = strtok((char *)salt, "$");
token = strtok(NULL, "$");
raw_password = strcat(token, pass);

mhash(handle, raw_password, 
strlen(raw_password));
hash = mhash_end(handle);
if (hash != NULL) {
buf_size = 
(mhash_get_block_size(MHASH_SHA1) * 2)+1;
buf = (char *)malloc(buf_size);
bzero(buf, buf_size);

for (i = 0; i < 
mhash_get_block_size(MHASH_SHA1); i++) {
sprintf([i * 2], "%.2x", 
hash[i]);
}
free(hash);

django_password = (char *)malloc(51);
django_password[0] = 's';
django_password[1] = 'h';
django_password[2] = 'a';
django_password[3] = '1';
django_password[4] = '$';
for (i = 5, j=0; i < 
(strlen(django_salt)+5); i++, j++) {
sprintf(_password[i], 
"%c", django_salt[j]);
}
django_password[i] = '$';

for (i = (i+1), j=0; i <= 50; i++, j++) 
{
sprintf(_password[i], 
"%c", buf[j]);
}
free(buf);
free(salt);
django_password[i+1] = '\0';

s = django_password;
} else {
s = strdup("!");
}
}
}
break;
>


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Databases, one or many

2007-09-06 Thread Brian Morton

Possibly.  I have never heard of this and I do not do it.  If I were
just making random applications for distribution to others I might
consider it, but most of the time I am making an application for a
specific purpose or organization/company.  In that case, I create a
project for the org/company/website and put the separate apps (based
on function) under the project.

On Sep 6, 4:49 pm, "Adam Jenkins" <[EMAIL PROTECTED]> wrote:
> On 9/6/07, Brian Morton <[EMAIL PROTECTED]> wrote:
>
>
>
> > Well, by its nature, each Django project has its own DB.  Multi-db
> > support is coming soon, but not in trunk yet.
>
> > If these are all applications that belong to the same project, Django
> > is not designed to handle them on a per-DB basis.  The convention
> > Django uses is a DB for the project and _ for the
> > tables.  This should not prevent any conflicts since a Python error
> > would occur if you duplicated a model within your app's model.  I am
> > not aware of any MySQL limit on tables per DB, nor should it make a
> > difference from a performance perspective.  Just keep in mind that
> > these apps will all share a single admin interface, and while there
> > are some access controls, they may not be granular enough for what you
> > need.  That may drive your requirement to move some of these apps to a
> > separate project.
>
> This actually brings up an issue. I've heard that many Django developers
> don't
> use projects at all, that they just use apps. Is this correct? Should I
> default to one
> project and break it up into smaller ones if the need arises?
>
> On Sep 6, 4:27 pm, "Adam Jenkins" <[EMAIL PROTECTED]> wrote:
>
> > > I'm moving old php apps to Django. All the old php apps each have their
> > own
> > > DB. So I'm deciding now if I should just put everything inside a big DB.
> > I
> > > think when I'm all done, I could easily push 200 tables. Almost all of
> > these
> > > are intranet apps, so the load is pretty small. Is one large DB an
> > issue, or
> > > are there any other problems I should look out for?
>
> > > --
> > > ---
> > > Adam Jenkins
> > > [EMAIL PROTECTED]
> > > 312-399-5161
> > > ---
>
> --
> ---
> Adam Jenkins
> [EMAIL PROTECTED]
> 312-399-5161
> ---


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Fixtures auto-incrementing primary keys?

2007-09-06 Thread Nathaniel Whiteinge

Can fixtures have auto-incrementing primary keys or must you have
specific PKs in the the serialized json/xml/etc files? If not, is
there a reason for this?

I'm programmatically generating fixtures from Freebase.org queries for
a project. Although it's not a much extra work to add a pk counter, it
is the second time this has struck me as annoying. Would the devs be
open to a patch for this sort of thing?

Thanks,
- whiteinge


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Databases, one or many

2007-09-06 Thread Adam Jenkins
On 9/6/07, Brian Morton <[EMAIL PROTECTED]> wrote:
>
>
> Well, by its nature, each Django project has its own DB.  Multi-db
> support is coming soon, but not in trunk yet.
>
> If these are all applications that belong to the same project, Django
> is not designed to handle them on a per-DB basis.  The convention
> Django uses is a DB for the project and _ for the
> tables.  This should not prevent any conflicts since a Python error
> would occur if you duplicated a model within your app's model.  I am
> not aware of any MySQL limit on tables per DB, nor should it make a
> difference from a performance perspective.  Just keep in mind that
> these apps will all share a single admin interface, and while there
> are some access controls, they may not be granular enough for what you
> need.  That may drive your requirement to move some of these apps to a
> separate project.


This actually brings up an issue. I've heard that many Django developers
don't
use projects at all, that they just use apps. Is this correct? Should I
default to one
project and break it up into smaller ones if the need arises?


On Sep 6, 4:27 pm, "Adam Jenkins" <[EMAIL PROTECTED]> wrote:
> > I'm moving old php apps to Django. All the old php apps each have their
> own
> > DB. So I'm deciding now if I should just put everything inside a big DB.
> I
> > think when I'm all done, I could easily push 200 tables. Almost all of
> these
> > are intranet apps, so the load is pretty small. Is one large DB an
> issue, or
> > are there any other problems I should look out for?
> >
> > --
> > ---
> > Adam Jenkins
> > [EMAIL PROTECTED]
> > 312-399-5161
> > ---
>
>
> >
>


-- 
---
Adam Jenkins
[EMAIL PROTECTED]
312-399-5161
---

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Storing Lookup Data

2007-09-06 Thread RajeshD

>
> It seems like the Choice table is easier on the user.  You tell them
> to go to the Choices table to enter all the look-up data, as opposed
> to giving them X tables to wade through.

As you said, it is probably a DB design question -- even within a
single project, you might need to use both approaches.

My $.02:

If you need special validation based on the type of the lookup data,
the separate tables option works better. You can still make them go to
one screen to manage all the lookup data (you're just going to have to
build that screen yourself ;)

Also, if you want foreign key relations to the choice data, separate
tables might work better.

I would personally never mix person name prefix data with a list of
states in the same table even if you have a "type" field to qualify
such data. To me, that kind of user convenience is not worth the loss
in data integrity because one can always unify those lookups in a user-
friendly UI.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Databases, one or many

2007-09-06 Thread Adam Jenkins
I'm moving old php apps to Django. All the old php apps each have their own
DB. So I'm deciding now if I should just put everything inside a big DB. I
think when I'm all done, I could easily push 200 tables. Almost all of these
are intranet apps, so the load is pretty small. Is one large DB an issue, or
are there any other problems I should look out for?

-- 
---
Adam Jenkins
[EMAIL PROTECTED]
312-399-5161
---

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using querysets to populate a form

2007-09-06 Thread RajeshD

> I have a requirement to use querysets as choices in various elements  
> of a form, and as the data grows this is clearly going to have a big  
> hit on the database every time this form is loaded.  Can anyone think  
> of a way around this?  Is there a way to cache the query set and only  
> update it every so often? Has anyone done anything similar?

You can always turn the queryset into a list and cache it with
Django's caching framework. However, that doesn't solve the usability
issue of a huge drop-down list. A few options:

1. Do what the Django raw_id_admin interface does (http://
www.djangoproject.com/documentation/model-api/#many-to-one-relationships).
It uses a popup-window in which the user sees the set of available
options (they could be paginated if it's a big list); clicking a row
results in its pk being fed back to the parent field being selected.

2. ExtJS (and possible other Javascript) libraries provide fancy AJAX
based interfaces that let you load a custom drop down list on demand
as the user scrolls down.



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tags within a textarea field

2007-09-06 Thread MichaelMartinides

On Sep 6, 9:18 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> On Sep 5, 12:03 pm, MichaelMartinides <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
>
> > Just to be sure.
>
> > If I have custom template tags within a TextAreafield of a model. I
> > would do something like to following:
>
> > def view(request, page):
> >   p = Page.objects.get(name=page)
> >   t = Template( p.content )
> >   content = t.render()
> >   return render_to_response('page.html', {content:content})
>
> > right?
>
> Right. Some gotchas to watch for:
>
> - If your template needs a context, be sure to call t.render with the
> context dictionary
>
> - p.content would've to be a self-contained template i.e. it should
> "load" the template tag libraries it needs like you would with a
> standard html template. Alternatively, you could add your custom
> templatetags to the built-in tag libraries using
> django.template.add_to_builtins.

Thanks for the heads-up (I thought about t = Template('{% load
customtags %}' + p.content) which probably is a brute force approach)

Cheers,
  >>MM


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unique_true option of the fields works as case-sensitive, how can we make it case-insensitive?

2007-09-06 Thread RajeshD



On Sep 4, 9:28 am, parabol <[EMAIL PROTECTED]> wrote:
> When I mark a field as unique_true is works as case-sensitive and does
> not catch something like "problem" and "Problem".  What is the correct
> way of making it case-insensitive? Thus it will catch even "problem"
> and "ProBLem".
>
> I tried to override the save() method, but this time the thrown
> exception (Integrity Error) is not catched by the admin form.
>
> What do you suggest?

1. Use a custom validator (you will need to make a DB call within your
validator to look for the existence of another record with the field
value in question)

2. Add a SlugField to your model, define it to be unique, and
prepopulate it from the field that's supposed to be case-insensitively
unique. Then, you will get the right validation errors in the admin
(but they will be shown against the slug field.)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: overriding save, non-admin error

2007-09-06 Thread RajeshD



On Sep 4, 7:18 am, canburak <[EMAIL PROTECTED]> wrote:
> I have a problem on overriding the save() method.
> my new save is:
> class ClassName:
>   def save(self):
> self.title = self.title.title()
> super(ClassName, self).save()
>
> when admin site uses this save(), I get the non-unique exception at
> django/python level but I hope to see a red box in the admin.  How can
> I do that?

You will need to add a custom validator to the title field of your
Model to check for uniqueness of its titlecased version.

The admin will check for uniqueness of self.title but it doesn't know
that you are titlecasing it later in your Model.save. So, it won't
know that the title "canburak" is not allowed even if you already have
a record with the title "Canburak" (before the Admin hits the save
method, those two strings look different to it.)

Another option is to add a slug field to your model, prepopulate it
from title, and make it unique (that will give you case-insensitive
uniqueness which you may or may not want.)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



'never_cache' decorator doesn't really prevent the page from being cached

2007-09-06 Thread Przemyslaw Wegrzyn

Hi!

I've tried to use never_cache from django.views.decorators.cache,
however my page was still getting cached by my ISP's transparent proxy
and/or my browser. I've checked that the headers that this decorator
adds were e.g.:

Expires: Thu, 06 Sep 2007 19:08:26 GMT
Last-Modified: Thu, 06 Sep 2007 19:08:27 GMT
ETag: 9b1e968e196553e7767d6378bfd0dc06
Cache-Control: max-age=0

For some reason it doesn't seem to reliably prevent from caching the
page (time/date setting on the proxy? assuming that the proxy can't deal
with  ETag. I had no time to investigate deeply).

The question is - how about equipping Django with a decrator that adds
typical 'Pragma: no-cache' (for HTTP/1.0) and 'Cache-Control: no-cache,
no-store' ? This is the most commonly used way, and it works perfectly
fine for me. 'Cache-Control: private' would do the trick as well.

Best Regards,
Przemyslaw


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tags within a textarea field

2007-09-06 Thread RajeshD



On Sep 5, 12:03 pm, MichaelMartinides <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> Just to be sure.
>
> If I have custom template tags within a TextAreafield of a model. I
> would do something like to following:
>
> def view(request, page):
>   p = Page.objects.get(name=page)
>   t = Template( p.content )
>   content = t.render()
>   return render_to_response('page.html', {content:content})
>
> right?

Right. Some gotchas to watch for:

- If your template needs a context, be sure to call t.render with the
context dictionary

- p.content would've to be a self-contained template i.e. it should
"load" the template tag libraries it needs like you would with a
standard html template. Alternatively, you could add your custom
templatetags to the built-in tag libraries using
django.template.add_to_builtins.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Translating strings with placeholder in template

2007-09-06 Thread RajeshD


> I think this would work with Python code. However, can I do the
> translation in Django's Template language? If so, how?

See blocktrans: 
http://www.djangoproject.com/documentation/i18n/#in-template-code

In short, you would use:
{% blocktrans %}login.before.you.proceed {{ login_url }}{%
endblocktrans %}

The .po file would be exactly what you have above:
msgid "login.before.you.proceed %(login_url)s"
msgstr "Please Login before you proceed"




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: forms, views and foreign key

2007-09-06 Thread RajeshD

> --
> so.. the problem is:
>
> Request Method: GET
> Request URL:http://127.0.0.1:8000/profile/
> Exception Type: AttributeError
> Exception Value:'Profile' object has no attribute 'get'
>
> what's wrong? :(
>

What line of code are you getting this error on? Can you paste the
stack trace as well?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



error: unsupported locale setting on windows machine

2007-09-06 Thread Subrat

I am currently building an app in windows machine which was already
built in unix machine. While running 'syncdb' command, I am getting
error 'unsupported locale setting'.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
>> 'English_United States.1252'

When I run this it returns error.
>>> locale.setlocale(locale.LC_ALL, "en_US")

An Error is raised: "unsupported locale setting" (lib/locale.py in
setlocale, line 476).

Dose anyone know how to fix this issue?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sporadic VariableDoesNotExist's...

2007-09-06 Thread Brian Morton

Also, do you have django.core.context_processors.request in your
context_processors?  It looks like you're trying to overwrite a dict
element that already exists.

On Sep 6, 12:14 pm, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Hello Everyone,
>
> I have a request context which sets {'request':request}...
>
> On windows (dev-server) everything is fine and dandy, but on our live
> site (splicemusic.com, Apache2 + mod_python) I see *sporadic*
> appearances of:
>
> "VariableDoesNotExist: Failed lookup for key [request] in [{}]"
>
> Does anyone have any idea what this could mean? The strange part is that
> the same page will sometimes trigger the error and sometimes... not!
>
>   - bram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sporadic VariableDoesNotExist's...

2007-09-06 Thread Brian Morton

Can we see your context processor code?

On Sep 6, 12:14 pm, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Hello Everyone,
>
> I have a request context which sets {'request':request}...
>
> On windows (dev-server) everything is fine and dandy, but on our live
> site (splicemusic.com, Apache2 + mod_python) I see *sporadic*
> appearances of:
>
> "VariableDoesNotExist: Failed lookup for key [request] in [{}]"
>
> Does anyone have any idea what this could mean? The strange part is that
> the same page will sometimes trigger the error and sometimes... not!
>
>   - bram


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: another complex SQL / extra() question

2007-09-06 Thread James Tauber


On Thu, 06 Sep 2007 11:59:35 -0500, "Tim Chase"
<[EMAIL PROTECTED]> said:
> It would help if you made a note of what "that doesn't work
> either" means. Perhaps the actual error message or perhaps the
> "wrong" resulting output along with the expected output.

Well, it turned out the lack of results (doesn't work = no results at
all) was a snafu on the templating side but I appreciate your SQL
insights which was a large part of what I was looking for advice on as
well.

James
-- 
  James Tauber   http://jtauber.com/
  journeyman of somehttp://jtauber.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: another complex SQL / extra() question

2007-09-06 Thread Tim Chase

>  SELECT t
>  FROM (
>  SELECT thing.thing_id AS t, COUNT 
> (thing.thing_id) AS c
>  FROM (
>  SELECT thing_id
>  FROM myapp_thing_sources
>  WHERE source_id = ...
>  ) AS thing, myapp_thing_sources
>  WHERE thing.thing_id = myapp_thing_sources.thing_id
>  GROUP BY thing.thing_id
>  )
>  WHERE c = 1;

Just as a SQL aside, this pattern

   SELECT 
   FROM (
 SELECT , count(*) AS c
 FROM 
 WHERE 
 GROUP BY 
   )
   WHERE c = 1

looks like the place to use the HAVING clause:

   SELECT 
   FROM 
   WHERE 
   GROUP BY 
   HAVING Count(*) = 1

(the HAVING clause allows you to do "WHERE"-like filtering on
aggregate results). I don't know if this impacts matters at all,
but it might make the query a little more readable. It might even
speed up the query as the underlying intent is explicit so the
SQL parser may be able to optimize it better.

I'm also confused by your query...it looks like you're pulling in
two instances of the same myapp_thing_sources table and then
doing a one-to-one join with itself. That leads me to believe
that the whole orginal convoluted snarl of SQL can be rewritten
more cleanly as

   .extra(where="""
  myapp_whatever.id IN (
   SELECT mts.thing_id
   FROM myapp_thing_sources mts
   WHERE mts.source_id = %s
   GROUP BY mts.thing_id
   HAVING Count(*) = 1
   )
 """, params=[source.id])

> .extra(where=["""
>  id IN (
>  SELECT t
>  FROM (
>  SELECT thing.thing_id AS t, COUNT 
> (thing.thing_id) AS c
>  FROM (
>  SELECT thing_id
>  FROM myapp_thing_sources
>  WHERE source_id = %s
>  ) AS thing, myapp_thing_sources
>  WHERE thing.thing_id = myapp_thing_sources.thing_id
>  GROUP BY thing.thing_id
>  )
>  WHERE c = 1
>  )
>  """], params=[source.id]
>  )
> 
> but that doesn't work either (even though the raw SQL does, 
> even with the WHERE id IN (...). )

It looks like it should be fairly kosher, though you might want
to explicitly give the id to make sure that you've got the ID you
want...something like

   myapp_whatever.id IN (...)

However, normally I would expect if more than one id column was
found in your query that you'd be getting errors from the SQL
engine telling you something like "more than one field called
'id'...please qualify it with the tablename".

   Whatever.objects.extra(...)._get_sql_clause()

returned and included it for diagnostic purposes (possibly mildly
redacting the data if needed, but the structure should be
unchanged). Fortunately, it's easy to dump the stuff of interest
to a file:

   f = file('.txt', 'w')
   f.write(repr(Whatever.objects.extra(...)._get_sql_clause()))
   f.write('\n')
   f.close()

> but that doesn't work either (even though the raw SQL does, 
> even with the WHERE id IN (...). )

It would help if you made a note of what "that doesn't work
either" means. Perhaps the actual error message or perhaps the
"wrong" resulting output along with the expected output.

I also presume you're not shifting DB engines between runs...I
know older MySQL installations were braindead in the sub-select
department. However, if you're using sqlite across the board, you
should be fine.

-tim





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej

On Thu, Sep 06, Nis Jørgensen wrote:

> 
> Michael Radziej skrev:
> > On Thu, Sep 06, Russell Keith-Magee wrote:
> >
> >   
> >> On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote:
> >> 
> >>> I'd *love* to have a sneak preview of your changes, any way? ;-)
> >>>   
> >> Hey! Get to the back of the line! No queue-jumping! I was here first! :-)
> >> 
> >
> > ... checking Malcolm's Amazone wishlist ...
> >   
> 
> If Malcolm is into Amazones, perhaps we should ask the Brasillian who
> just registered for the sprint :-)

Oopsie ;-)


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sporadic VariableDoesNotExist's...

2007-09-06 Thread Bram - Smartelectronix

Hello Everyone,


I have a request context which sets {'request':request}...

On windows (dev-server) everything is fine and dandy, but on our live 
site (splicemusic.com, Apache2 + mod_python) I see *sporadic* 
appearances of:

"VariableDoesNotExist: Failed lookup for key [request] in [{}]"


Does anyone have any idea what this could mean? The strange part is that 
the same page will sometimes trigger the error and sometimes... not!


  - bram

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: another complex SQL / extra() question

2007-09-06 Thread Nis Jørgensen

James Tauber skrev:
> As before, I have a Thing model with a many-to-many relationship to  
> Source.
>
> For a given Source, I want to find those Things that come only from  
> that Source.
>
> This SQL works fine in dbshell (on sqlite):
>
>  SELECT t
>  FROM (
>  SELECT thing.thing_id AS t, COUNT 
> (thing.thing_id) AS c
>  FROM (
>  SELECT thing_id
>  FROM myapp_thing_sources
>  WHERE source_id = ...
>  ) AS thing, myapp_thing_sources
>  WHERE thing.thing_id = myapp_thing_sources.thing_id
>  GROUP BY thing.thing_id
>  )
>  WHERE c = 1;
>
> (where ... is the id of the given Source)
>
>
> But I can't seem to get it to work with extra(). Firstly I wasn't  
> sure how to do a fully explicit select so I wrapped it in a WHERE id  
> IN (...):
>
> .extra(where=["""
>  id IN (
>  SELECT t
>  FROM (
>  SELECT thing.thing_id AS t, COUNT 
> (thing.thing_id) AS c
>  FROM (
>  SELECT thing_id
>  FROM myapp_thing_sources
>  WHERE source_id = %s
>  ) AS thing, myapp_thing_sources
>  WHERE thing.thing_id = myapp_thing_sources.thing_id
>  GROUP BY thing.thing_id
>  )
>  WHERE c = 1
>  )
>  """], params=[source.id]
>  )
>
> but that doesn't work either (even though the raw SQL does, even with  
> the WHERE id IN (...). )
>
> Any ideas?
>   
Idea #1:
Be more specific than "does not work"

#2:
Find out what SQL is generated, and how it differs from what you run
from the dbshell

Yours,
Nis Jørgensen
No House 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How run a python script as standalone? (aka: Why django need the DJANGO_SETTINGS_MODULE anyway???)

2007-09-06 Thread James Bennett

On 9/6/07, mamcxyz <[EMAIL PROTECTED]> wrote:
> Yeah, and maybe in mod_python I see the purpose... however why not
> doing that to a single import anyway? And for fastcgi and the dev web
> server that could by that simply... not?

"A single import" from where, exactly? Either you set
DJANGO_SETTINGS_MODULE, or you manually configure the settings. Either
works, but Django has to have *some* way of finding the necessary
settings.


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

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



another complex SQL / extra() question

2007-09-06 Thread James Tauber


As before, I have a Thing model with a many-to-many relationship to  
Source.

For a given Source, I want to find those Things that come only from  
that Source.

This SQL works fine in dbshell (on sqlite):

 SELECT t
 FROM (
 SELECT thing.thing_id AS t, COUNT 
(thing.thing_id) AS c
 FROM (
 SELECT thing_id
 FROM myapp_thing_sources
 WHERE source_id = ...
 ) AS thing, myapp_thing_sources
 WHERE thing.thing_id = myapp_thing_sources.thing_id
 GROUP BY thing.thing_id
 )
 WHERE c = 1;

(where ... is the id of the given Source)


But I can't seem to get it to work with extra(). Firstly I wasn't  
sure how to do a fully explicit select so I wrapped it in a WHERE id  
IN (...):

.extra(where=["""
 id IN (
 SELECT t
 FROM (
 SELECT thing.thing_id AS t, COUNT 
(thing.thing_id) AS c
 FROM (
 SELECT thing_id
 FROM myapp_thing_sources
 WHERE source_id = %s
 ) AS thing, myapp_thing_sources
 WHERE thing.thing_id = myapp_thing_sources.thing_id
 GROUP BY thing.thing_id
 )
 WHERE c = 1
 )
 """], params=[source.id]
 )

but that doesn't work either (even though the raw SQL does, even with  
the WHERE id IN (...). )

Any ideas?


James
--
James Tauber  http://jtauber.com/
journeyman of some   http://jtauber.com/blog/





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Nis Jørgensen

Michael Radziej skrev:
> On Thu, Sep 06, Russell Keith-Magee wrote:
>
>   
>> On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote:
>> 
>>> I'd *love* to have a sneak preview of your changes, any way? ;-)
>>>   
>> Hey! Get to the back of the line! No queue-jumping! I was here first! :-)
>> 
>
> ... checking Malcolm's Amazone wishlist ...
>   

If Malcolm is into Amazones, perhaps we should ask the Brasillian who
just registered for the sprint :-)

-- 
Nis Jorgensen
Hand crafting signatures since 1996

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Integrating Django with existing site.

2007-09-06 Thread Ray Cote

At 4:22 PM + 9/5/07, Steve  Potter wrote:
>  >
>>  Try coding each module as a Django template tag.
>>  Then, create a template that returns an html fragment rather than a
>>  full html page.
>>  Associate each rendered template with a specific URL.
>>  Perhaps something like:
>>mysite.com/components/module1.html
>>  In Joomla, create a plug-in that simply calls the component.
>>
>>  As you migrate away from Joomla to Django, simply use the template
>>  tag directly in your Django template so you don't need to make the
>>  extra call.
>>  --Ray
>
>Ray,
>
>That sounds like it work work.  The only thing I am having a hard time
>understanding is how the request is made from the php script to
>Django.  Would it be best to make the request to the localhost using
>something like CURL?
>
>Thanks,
>
>Steve

Hi Steve:
Doing an HTTP call is indeed the way to go.
Afraid I don't know the PHP library well enough to answer that definitively.
A quick Google found the following reference calling without CURL.


I'd stay away from Curl simply because I would not want to launch a 
new app each time the remote query needs to be run.  A pure PHP 
solution would be preferable. (also less worry about the security of 
passing a command-line parameter to the curl call).
--Ray


-- 

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Signing with mouse

2007-09-06 Thread Nis Jørgensen

Kelsey Ruger skrev:
> I am looking for a python based utility that will allow a user to sign
> their name with a mouse and save the resulting image for inclusion in
> a PDF. Has anyone heard of something like this?
>   
A word of warning: Users may not be able to prodcue anythin that looks
like their normal written signature. I just tried, and I couldn't.

Nis

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej

On Thu, Sep 06, Russell Keith-Magee wrote:

> 
> On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote:
> >
> > I'd *love* to have a sneak preview of your changes, any way? ;-)
> 
> Hey! Get to the back of the line! No queue-jumping! I was here first! :-)

... checking Malcolm's Amazone wishlist ...

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to implement 3X2 lines?

2007-09-06 Thread [EMAIL PROTECTED]

I wrote this tag a couple months ago that should be of some help.
http://www.djangosnippets.org/snippets/296/
You can at least use it as a starting point for your own tag.

On Sep 6, 8:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> need your help, thx
>
> On 9月6日, 下午3时21分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:> sorry, i am 
> a newbie to python.
> > i have a queryset with 6 record, i want to show in 3 col and 2 row,
> > how to do this, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee

On 9/6/07, Michael Radziej <[EMAIL PROTECTED]> wrote:
>
> I'd *love* to have a sneak preview of your changes, any way? ;-)

Hey! Get to the back of the line! No queue-jumping! I was here first! :-)

Yours
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Michael Radziej

Hi Malcolm,

On Fri, Sep 07, Malcolm Tredinnick wrote:

> My bad; you're right. Only m2m does outer joins on trunk at the
> moment.:(
> 
> I've been looking at the new stuff too much lately. This problem is
> fixed there, so if people can wait until that lands very shortly it will
> go away.

this had been changed to outer joins, and was then reverted due to
problems with mysql (which isn't very cluefull about outer joins).

I'd *love* to have a sneak preview of your changes, any way? ;-)

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Djangonauts in Sweden?

2007-09-06 Thread Emil

Nice to make your acquaintance, Nis!

Yeah, I would really like to have some sort of meetup sometime. The
14th is out of the question though, I have work at my old job (night
shift at that). This is the last month I work there, so I'll spend the
night blocking Visa cards per the requests of drunken swedes, but come
October: no more. :-)

I know at least one Django developer here in Malmö, not personally but
we have had contact via email briefly. If we put something together
I'll let him know, if he's not reading this. Too bad no one else has
replied. (Yet, that is.) Where are you, swedes?

Nice to hear that you're into web standards too, standards and best-
practices are real important to me. I'm an ambassador for WaSP ILG
(Web Standards Project International Liaisons Group) in Sweden, btw.
Unless you've heard of it, it's a "grassroots coalition" of web-people
from all over the world, aiming to promote sharing of knowledge and
spreading standards awareness globally, among other things.

Just for the record, I'm probably considered a newbie by any standard
when it comes to Python and OOP, so I'm just beginning to learn, but I
have some fairly strong HTML/CSS skills and a decent general knowledge
in the IT field, and I think I'm a pretty fast learner. Which means
I'll be in "sponge-mode" and just try to absorb as much as I can when
it comes to Django. Or we could just compare rants on the importance
of web standards. Over 2+ beers. :-)

Let's keep in touch about this, and I hope other swedes (and more
danes) join in too. E-mail me directly if there are any specific
plans, Nis, and I'll do the same.

(Now I'm off to the first day of work as a tutor: wish me luck trying
to teach computer beginners find their Home-drive on the school
network.)

Cheers,
Emil

On Sep 6, 4:09 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> Nis Jørgensen skrev:
>
> > Emil Björklund skrev:
>
> >> Hi folks,
>
> >> Two part post:
>
> >> 1. Just wanted to introduce myself: Emil, web designer/developer from
> >> Malmö in southern Sweden, studying Information Architecture at Malmö
> >> University where I also work as a tutor.
> >> Come mostly from a php background, not much of a programmer in any
> >> language but I get by on curiosity and googling. Discovered Django
> >> about a year ago, got really into it because of an extremely rainy
> >> summer in Sweden. So far, I love it! My "research" so far into
> >> django-land has left the conclusion that pretty much everything about
> >> it is well thought-out and developer/designer friendly.
>
> >> 2. Any Swedish djangonauts out there? And more specifically, anyone in
> >> Malmö? I would love to get in touch with people around here, maybe
> >> grab a beer or coffee and talk shop. I'm no authority, so don't get
> >> your hopes up about learning much from me (apart from maybe some
> >> basics & terminology), but I still believe that anyone can learn from
> >> anybody else, pretty much... Sharing is caring!
>
> > Well, I am in Copenhagen and willing to travel. It would have to be at
> > least two beers to make it worthwhile, though ;-)
>
> > About me: Freelance developer and general IT-person. Currently working
> > with php/mysql and Django/postgres (which currently is my framework of
> > choice). I'm into web standards[1]
>
> > I would love to help arrange some kind of meet up - perhaps do a quick
> > introduction for people who don't know Django (I could imagine bringing
> > some along).
>
> I just saw the plan for a sprint on September 14th . I could host an
> event in Copenhagen (quite close to the Central Station), or come to
> Malmö. Would you be interested and able? I will (probably) be able to
> offer sleeping on an office floor, anything fancier you would need to
> arrange yourself.
>
> So far, I have identified one other cluster of Danish Django developers
> - unfortunately in the other end of the country: They can hereby
> consider themselves invited as well.
>
> http://www.iola.dk/(in Danish).
>
> Nis Jørgensen
> No House IT
>
> [1] At this point of my original mail, I was planning to insert some
> longer rant about web standards and why I find them important.
> Unfortunately, I completely forgot about this plan at the time when my
> fingers decided to press "send".


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Q lookup with both OR and AND

2007-09-06 Thread Nis Jørgensen

[EMAIL PROTECTED] skrev:
> I'm having trouble piecing together a query for this model:
>
> class Ticket(models.Model):
> ...
> assigned_user = models.ForeignKey(User)
> name = models.CharField(maxlength=255)
> private = models.BooleanField(default=False)
>
> I'm trying to get all the tickets where the tickets are not private OR
> the ticket is private and assigned to the current user.
>
> I'm foggy on where I use the comma, pipe, and ampersand characters to
> get the query structured properly. In pseudo-sql, I'd say "select *
> where private = False or (private=True and username='snewman')
>
> I thought I was close with this, but it only returned tickets assigned
> to me. (The parenthesis around the 2nd and 3rd Q's obviously didn't
> help)
>
> Ticket.objects.filter(Q(private__exact=False) |
> (Q(private__exact=True) & Q(assigned_user__username__exact='snewman')))
>   
I don't know why this does not work. Could it be that the db somehow
contains NULL's rather than False? Could you try the output of 
your_queryset._get_sql_clause()?

Anyway, since

A OR (NOT A AND B)
<=> (A OR NOT A) AND (A OR B)
<=> TRUE AND  (A OR B)
<=> A OR B

your query can be reduced to

Q(private__exact=False) | Q(assigned_user__username__exact='snewman')

Which is simpler, but probably does not work either.

Nis Jorgensen
No House 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Q lookup with both OR and AND

2007-09-06 Thread Nis Jørgensen

Michael Radziej skrev:
> On Thu, Sep 06, [EMAIL PROTECTED] wrote:
>
>   
>> I thought I was close with this, but it only returned tickets assigned
>> to me. (The parenthesis around the 2nd and 3rd Q's obviously didn't
>> help)
>>
>> Ticket.objects.filter(Q(private__exact=False) |
>> (Q(private__exact=True) & Q(assigned_user__username__exact='snewman')))
>> 
>
> Well, that's a known bug. Django uses inner joins even when combining
> queries. A refactoring of the ORM is on the way, in the mean time you could
> only either write custom SQL or resort to multiple queries.
>   
Since "user" is a required field, this bug should not affect this case
AFAICS.

Nis



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Mysql database

2007-09-06 Thread Nis Jørgensen

Nader skrev:
> I have used 'inspectdb' to produce the model, because I had a dump
> mysql file. In Meta section of model I have defined the table name:
>
> class Meta:
> db_table = 'Dataset'
>
> Besides If I check the application model with "python manage.py sqlall
> dataset" I see the same  name which has been defined in Meta class.
>
> BEGIN;
> CREATE TABLE `Dataset`
>   

you may have both a table "Dataset" and a table "dataset":

http://dev.mysql.com/doc/refman/4.1/en/identifier-case-sensitivity.html


Nis Jorgensen
No House 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Malcolm Tredinnick

On Thu, 2007-09-06 at 21:25 +0800, Russell Keith-Magee wrote:
> On 9/6/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > > When you run Question.objects.filter(answer__isnull=True), this gets
> > > turned into an SQL query something like:
> > >
> > > SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> > > Answer.question_id WHERE Answer.id IS NULL
> >
> > Umm, no it doesn't. :-)
> >
> > It gets turned into a join using LEFT OUTER JOIN always. so entries not
> > appearing in the right hand table will still appear in the result set.
> 
> Erm... except when it does :-)
> 
> Vis, line 1064 and 1089 of current trunk query.py. Its been a while,
> but IIRC, 1089 is the bit dealing with 1-N relations.

My bad; you're right. Only m2m does outer joins on trunk at the
moment.:(

I've been looking at the new stuff too much lately. This problem is
fixed there, so if people can wait until that lands very shortly it will
go away.

Malcolm

-- 
Everything is _not_ based on faith... take my word for it. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Djangonauts in Sweden?

2007-09-06 Thread Nis Jørgensen

Nis Jørgensen skrev:
> Emil Björklund skrev:
>   
>> Hi folks,
>>
>> Two part post:
>>
>> 1. Just wanted to introduce myself: Emil, web designer/developer from
>> Malmö in southern Sweden, studying Information Architecture at Malmö
>> University where I also work as a tutor.
>> Come mostly from a php background, not much of a programmer in any
>> language but I get by on curiosity and googling. Discovered Django
>> about a year ago, got really into it because of an extremely rainy
>> summer in Sweden. So far, I love it! My "research" so far into
>> django-land has left the conclusion that pretty much everything about
>> it is well thought-out and developer/designer friendly.
>>
>> 2. Any Swedish djangonauts out there? And more specifically, anyone in
>> Malmö? I would love to get in touch with people around here, maybe
>> grab a beer or coffee and talk shop. I'm no authority, so don't get
>> your hopes up about learning much from me (apart from maybe some
>> basics & terminology), but I still believe that anyone can learn from
>> anybody else, pretty much... Sharing is caring!
>> 
> Well, I am in Copenhagen and willing to travel. It would have to be at
> least two beers to make it worthwhile, though ;-)
>
> About me: Freelance developer and general IT-person. Currently working
> with php/mysql and Django/postgres (which currently is my framework of
> choice). I'm into web standards[1]
>
> I would love to help arrange some kind of meet up - perhaps do a quick
> introduction for people who don't know Django (I could imagine bringing
> some along).
>   
I just saw the plan for a sprint on September 14th . I could host an
event in Copenhagen (quite close to the Central Station), or come to
Malmö. Would you be interested and able? I will (probably) be able to
offer sleeping on an office floor, anything fancier you would need to
arrange yourself.

So far, I have identified one other cluster of Danish Django developers
- unfortunately in the other end of the country: They can hereby
consider themselves invited as well.

http://www.iola.dk/ (in Danish).

Nis Jørgensen
No House IT

[1] At this point of my original mail, I was planning to insert some
longer rant about web standards and why I find them important.
Unfortunately, I completely forgot about this plan at the time when my
fingers decided to press "send".


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread omat

When I checked the queries generated, it appears that the isnull
lookups result in INNER JOINs for my case.



On 6 Eylül, 16:38, omat <[EMAIL PROTECTED]> wrote:
> Malcolm, these are the models:
>
> class Question(models.Model):
> question = models.CharField(max_length=150)
> slug = models.SlugField(max_length=150,
> editable=False)
> verb = models.ForeignKey(Verb)
> added = models.DateTimeField(editable=False)
> user = models.ForeignKey(User)
>
> class Answer(models.Model):
> question = models.ForeignKey(Question)
> answer = models.PositiveSmallIntegerField(choices=((1, 'Yes'), (2,
> 'No')))
> user = models.ForeignKey(User)
> added = models.DateTimeField(editable=False)
>
> On 6 Eylül, 16:34, omat <[EMAIL PROTECTED]> wrote:
>
> > Thanks for clarifying this with such a detailed explanation.
>
> > I took the first way you have suggested and get things working with
> > the following manager:
>
> > class QuestionManager(models.Manager):
> > def get_not_answered(self):
> > cursor = connection.cursor()
> > cursor.execute("""SELECT questions_question.id
> >   FROM questions_question
> >   LEFT JOIN questions_answer
> >   ON questions_question.id =
> > questions_answer.question_id
> >   GROUP BY questions_question.id,
> > questions_answer.id
> >   HAVING questions_answer.id IS NULL""")
> > rows = cursor.fetchall()
> > ids = [row[0] for row in rows]
> > cursor.close()
> > return self.filter(id__in=ids)
>
> > Regards,
> > oMat
>
> > On 6 Eylül, 15:59, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
>
> > > On 9/6/07, omat <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > For Question & Answer models:
>
> > > > Question.objects.filter(answer__isnull=False)
>
> > > > returns the set of questions that has at least one answer, but:
>
> > > > Question.objects.filter(answer__isnull=True)
>
> > > > does not return the questions that has no answer.
>
> > > > Am I missing something?
>
> > > Somewhat. The problem is that 'isnull' isn't doing what you think it does.
>
> > > When you run Question.objects.filter(answer__isnull=True), this gets
> > > turned into an SQL query something like:
>
> > > SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> > > Answer.question_id WHERE Answer.id IS NULL
>
> > > In evaluating this query, this generates an internal table containing
> > > the columns:
> > > Question.id
> > > Question.field1
> > > Question.field2,
> > > ...
> > > Answer.id
> > > Answer.field1
> > > Answer.field2
>
> > > This internal table is then truncated, and only the Question columns
> > > are returned to create Question Django objects.
>
> > > This internal table will contain a row for every Question+Answer pair
> > > where the answer points at the question. If there is no answer to join
> > > with a question, then there will be no answer in the result set.
>
> > > Hence, when you ask for answer__isnull=False - you get all the rows
> > > that are returned. If you ask for answer__isnull=True, you get nothing
> > > - because there can't be an answer-null row that is joined with a
> > > Question.
>
> > > Now - I'm sure the next question is "how to I get all questions that
> > > have at least one answer".
> > > The best SQL way to do this is with an aggregate clause, exploiting
> > > GROUP BY and HAVING to establish how many joined objects exist.
> > > However, Django doesn't currently have good support for aggregate
> > > clauses (something I'm hoping to rectify soon).
>
> > > An alternate approach is to do it in two steps: get a list of all
> > > answers, find the unique question ids (using distinct() and values()
> > > clauses), and then ask for Question.objects.filter(id__in=[list of
> > > ids]), or Question.objects.exclude(id__in=[list of ids]).
>
> > > Yours,
> > > Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread omat

Malcolm, these are the models:

class Question(models.Model):
question = models.CharField(max_length=150)
slug = models.SlugField(max_length=150,
editable=False)
verb = models.ForeignKey(Verb)
added = models.DateTimeField(editable=False)
user = models.ForeignKey(User)


class Answer(models.Model):
question = models.ForeignKey(Question)
answer = models.PositiveSmallIntegerField(choices=((1, 'Yes'), (2,
'No')))
user = models.ForeignKey(User)
added = models.DateTimeField(editable=False)




On 6 Eylül, 16:34, omat <[EMAIL PROTECTED]> wrote:
> Thanks for clarifying this with such a detailed explanation.
>
> I took the first way you have suggested and get things working with
> the following manager:
>
> class QuestionManager(models.Manager):
> def get_not_answered(self):
> cursor = connection.cursor()
> cursor.execute("""SELECT questions_question.id
>   FROM questions_question
>   LEFT JOIN questions_answer
>   ON questions_question.id =
> questions_answer.question_id
>   GROUP BY questions_question.id,
> questions_answer.id
>   HAVING questions_answer.id IS NULL""")
> rows = cursor.fetchall()
> ids = [row[0] for row in rows]
> cursor.close()
> return self.filter(id__in=ids)
>
> Regards,
> oMat
>
> On 6 Eylül, 15:59, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
> > On 9/6/07, omat <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > For Question & Answer models:
>
> > > Question.objects.filter(answer__isnull=False)
>
> > > returns the set of questions that has at least one answer, but:
>
> > > Question.objects.filter(answer__isnull=True)
>
> > > does not return the questions that has no answer.
>
> > > Am I missing something?
>
> > Somewhat. The problem is that 'isnull' isn't doing what you think it does.
>
> > When you run Question.objects.filter(answer__isnull=True), this gets
> > turned into an SQL query something like:
>
> > SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> > Answer.question_id WHERE Answer.id IS NULL
>
> > In evaluating this query, this generates an internal table containing
> > the columns:
> > Question.id
> > Question.field1
> > Question.field2,
> > ...
> > Answer.id
> > Answer.field1
> > Answer.field2
>
> > This internal table is then truncated, and only the Question columns
> > are returned to create Question Django objects.
>
> > This internal table will contain a row for every Question+Answer pair
> > where the answer points at the question. If there is no answer to join
> > with a question, then there will be no answer in the result set.
>
> > Hence, when you ask for answer__isnull=False - you get all the rows
> > that are returned. If you ask for answer__isnull=True, you get nothing
> > - because there can't be an answer-null row that is joined with a
> > Question.
>
> > Now - I'm sure the next question is "how to I get all questions that
> > have at least one answer".
> > The best SQL way to do this is with an aggregate clause, exploiting
> > GROUP BY and HAVING to establish how many joined objects exist.
> > However, Django doesn't currently have good support for aggregate
> > clauses (something I'm hoping to rectify soon).
>
> > An alternate approach is to do it in two steps: get a list of all
> > answers, find the unique question ids (using distinct() and values()
> > clauses), and then ask for Question.objects.filter(id__in=[list of
> > ids]), or Question.objects.exclude(id__in=[list of ids]).
>
> > Yours,
> > Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread omat

Thanks for clarifying this with such a detailed explanation.

I took the first way you have suggested and get things working with
the following manager:

class QuestionManager(models.Manager):
def get_not_answered(self):
cursor = connection.cursor()
cursor.execute("""SELECT questions_question.id
  FROM questions_question
  LEFT JOIN questions_answer
  ON questions_question.id =
questions_answer.question_id
  GROUP BY questions_question.id,
questions_answer.id
  HAVING questions_answer.id IS NULL""")
rows = cursor.fetchall()
ids = [row[0] for row in rows]
cursor.close()
return self.filter(id__in=ids)


Regards,
oMat


On 6 Eylül, 15:59, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 9/6/07, omat <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > For Question & Answer models:
>
> > Question.objects.filter(answer__isnull=False)
>
> > returns the set of questions that has at least one answer, but:
>
> > Question.objects.filter(answer__isnull=True)
>
> > does not return the questions that has no answer.
>
> > Am I missing something?
>
> Somewhat. The problem is that 'isnull' isn't doing what you think it does.
>
> When you run Question.objects.filter(answer__isnull=True), this gets
> turned into an SQL query something like:
>
> SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> Answer.question_id WHERE Answer.id IS NULL
>
> In evaluating this query, this generates an internal table containing
> the columns:
> Question.id
> Question.field1
> Question.field2,
> ...
> Answer.id
> Answer.field1
> Answer.field2
>
> This internal table is then truncated, and only the Question columns
> are returned to create Question Django objects.
>
> This internal table will contain a row for every Question+Answer pair
> where the answer points at the question. If there is no answer to join
> with a question, then there will be no answer in the result set.
>
> Hence, when you ask for answer__isnull=False - you get all the rows
> that are returned. If you ask for answer__isnull=True, you get nothing
> - because there can't be an answer-null row that is joined with a
> Question.
>
> Now - I'm sure the next question is "how to I get all questions that
> have at least one answer".
> The best SQL way to do this is with an aggregate clause, exploiting
> GROUP BY and HAVING to establish how many joined objects exist.
> However, Django doesn't currently have good support for aggregate
> clauses (something I'm hoping to rectify soon).
>
> An alternate approach is to do it in two steps: get a list of all
> answers, find the unique question ids (using distinct() and values()
> clauses), and then ask for Question.objects.filter(id__in=[list of
> ids]), or Question.objects.exclude(id__in=[list of ids]).
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How run a python script as standalone? (aka: Why django need the DJANGO_SETTINGS_MODULE anyway???)

2007-09-06 Thread mamcxyz

Yeah, and maybe in mod_python I see the purpose... however why not
doing that to a single import anyway? And for fastcgi and the dev web
server that could by that simply... not?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee

On 9/6/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > When you run Question.objects.filter(answer__isnull=True), this gets
> > turned into an SQL query something like:
> >
> > SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> > Answer.question_id WHERE Answer.id IS NULL
>
> Umm, no it doesn't. :-)
>
> It gets turned into a join using LEFT OUTER JOIN always. so entries not
> appearing in the right hand table will still appear in the result set.

Erm... except when it does :-)

Vis, line 1064 and 1089 of current trunk query.py. Its been a while,
but IIRC, 1089 is the bit dealing with 1-N relations.

Russ %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Malcolm Tredinnick

On Thu, 2007-09-06 at 20:59 +0800, Russell Keith-Magee wrote:
> On 9/6/07, omat <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > For Question & Answer models:
> >
> > Question.objects.filter(answer__isnull=False)
> >
> > returns the set of questions that has at least one answer, but:
> >
> > Question.objects.filter(answer__isnull=True)
> >
> > does not return the questions that has no answer.
> >
> > Am I missing something?
> 
> Somewhat. The problem is that 'isnull' isn't doing what you think it does.
> 
> When you run Question.objects.filter(answer__isnull=True), this gets
> turned into an SQL query something like:
> 
> SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
> Answer.question_id WHERE Answer.id IS NULL

Umm, no it doesn't. :-)

It gets turned into a join using LEFT OUTER JOIN always. so entries not
appearing in the right hand table will still appear in the result set.

Querying isnull=True does work with m2m relation, so perhaps the
original poster needs to post the models he is using. One example that
shows this works (in this case, Entry is a model with a nullable
ManyToManyField called 'tags' that links to the Tag model):

In [2]: Entry.objects.filter(tags__isnull=True)
Out[2]: [, , ]

All those Entry objects do indeed have e.tags.all() being empty.

Regards,
Malcolm

-- 
Monday is an awful way to spend 1/7th of your life. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



nesh thumbnails error after moving to unicode

2007-09-06 Thread Kenneth Gonsalves

hi,

after upgrading to the unicode (latest svn head) nesh thumbnails dont  
work saying: TypeError, Make_thumbnail() keywords must be strings.  
Any clues?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problems with finnish after upgrading to latest svn head

2007-09-06 Thread Michael Radziej

On Thu, Sep 06, Kenneth Gonsalves wrote:

> 
> 
> On 06-Sep-07, at 4:27 PM, Chris Hoeppner wrote:
> 
> > Make sure you're serving the content with the right content type in
> > HTML, and that Django is working with the right content type, and that
> > the files have a coding declared.
> 
> all this is correctly done - it was working before I upgraded to svn  
> trunk (i was working in non-unicode previously, and am in unicode now.

You should check the unicode documentation, 
http://www.djangoproject.com/unicode/

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: isnull lookup's contradicting result

2007-09-06 Thread Russell Keith-Magee

On 9/6/07, omat <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> For Question & Answer models:
>
> Question.objects.filter(answer__isnull=False)
>
> returns the set of questions that has at least one answer, but:
>
> Question.objects.filter(answer__isnull=True)
>
> does not return the questions that has no answer.
>
> Am I missing something?

Somewhat. The problem is that 'isnull' isn't doing what you think it does.

When you run Question.objects.filter(answer__isnull=True), this gets
turned into an SQL query something like:

SELECT Question.* from Question INNER JOIN Answer WHERE Question.id =
Answer.question_id WHERE Answer.id IS NULL

In evaluating this query, this generates an internal table containing
the columns:
Question.id
Question.field1
Question.field2,
...
Answer.id
Answer.field1
Answer.field2

This internal table is then truncated, and only the Question columns
are returned to create Question Django objects.

This internal table will contain a row for every Question+Answer pair
where the answer points at the question. If there is no answer to join
with a question, then there will be no answer in the result set.

Hence, when you ask for answer__isnull=False - you get all the rows
that are returned. If you ask for answer__isnull=True, you get nothing
- because there can't be an answer-null row that is joined with a
Question.

Now - I'm sure the next question is "how to I get all questions that
have at least one answer".
The best SQL way to do this is with an aggregate clause, exploiting
GROUP BY and HAVING to establish how many joined objects exist.
However, Django doesn't currently have good support for aggregate
clauses (something I'm hoping to rectify soon).

An alternate approach is to do it in two steps: get a list of all
answers, find the unique question ids (using distinct() and values()
clauses), and then ask for Question.objects.filter(id__in=[list of
ids]), or Question.objects.exclude(id__in=[list of ids]).

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms edit_inline formsets

2007-09-06 Thread patrickk

it´s not so much about "adventurous", but about getting the deadline.
guess I´ll stick with manually doing it.

thanks,
patrick

On 6 Sep., 13:34, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 9/6/07, patrickk <[EMAIL PROTECTED]> wrote:
>
>
>
> > I´m having 2 models, where one is edited inline.
> > Now, I have to make some customization to the admins add- and change-
> > form (view and template).
>
> > Question is: Should I go for formsets.py in the newadmin-branch or is
> > there another (maybe easier) possibility?
> > If I should use formsets.py, does anyone have an example on how to use
> > it?
>
> Depends a little on how adventurous you are feeling. Your options are:
> - Manually roll out the whole form
> - Hand write a form generating mechanism that works for your model
> - Try to work out how to use formsets.
>
> I'm using formsets on a project at work, and haven't had any major
> problems, so the third option is definitely viable.
>
> However, there isn't much by way of helpful documentation or examples.
> At this point, the best documentation is the test code and the way
> newforms-admin uses formsets.
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Mysql database

2007-09-06 Thread Nader

I have used 'inspectdb' to produce the model, because I had a dump
mysql file. In Meta section of model I have defined the table name:

class Meta:
db_table = 'Dataset'

Besides If I check the application model with "python manage.py sqlall
dataset" I see the same  name which has been defined in Meta class.

BEGIN;
CREATE TABLE `Dataset`

Yours,
Nader

On Sep 6, 1:40 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 9/6/07, Nader <[EMAIL PROTECTED]> wrote:
>
>
>
> > I can directly get information from mysql session :
>
> > mysql> select datasetname from  dataset;
> ...
> > But if I want to get  information of the same dataset I got the empty
> > list:
>
> > >>> from ipdc.dataset.models import Dataset
> > >>> Dataset.objects.all()
> > []
>
> > What is actually here wrong? Have I got forgotten something?
> > Would somebody tell me how I can solve this problem?
>
> My initial guess would be that you're not looking at the same table.
> Your SQL session is looking at a table called 'dataset' - unless
> you're using a Meta option, this won't be the name of your table as
> far as Django is concerned. Django will be looking at a table called
> 'appname_dataset'.
>
> If you actually want Django to look in the 'dataset' table, rather
> than the name Django creates, look in the Django docs for the Model
> Meta option 'db_table'.
>
> Yours,
> Russ Magee %-)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to implement 3X2 lines?

2007-09-06 Thread [EMAIL PROTECTED]

need your help, thx

On 9月6日, 下午3时21分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> sorry, i am a newbie to python.
> i have a queryset with 6 record, i want to show in 3 col and 2 row,
> how to do this, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding field to model

2007-09-06 Thread Alex Koshelev

http://code.djangoproject.com/wiki/SchemaEvolution

On 6 сент, 14:51, ksuess <[EMAIL PROTECTED]> wrote:
> hi. I had to add a field to an existing model. how do i update the db?
> (of course there is content.)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



isnull lookup's contradicting result

2007-09-06 Thread omat

Hi,

For Question & Answer models:

Question.objects.filter(answer__isnull=False)

returns the set of questions that has at least one answer, but:

Question.objects.filter(answer__isnull=True)

does not return the questions that has no answer.

Am I missing something?


Thanks,
oMat


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Mysql database

2007-09-06 Thread Russell Keith-Magee

On 9/6/07, Nader <[EMAIL PROTECTED]> wrote:
>
> I can directly get information from mysql session :
>
> mysql> select datasetname from  dataset;
...
> But if I want to get  information of the same dataset I got the empty
> list:
>
> >>> from ipdc.dataset.models import Dataset
> >>> Dataset.objects.all()
> []
>
> What is actually here wrong? Have I got forgotten something?
> Would somebody tell me how I can solve this problem?

My initial guess would be that you're not looking at the same table.
Your SQL session is looking at a table called 'dataset' - unless
you're using a Meta option, this won't be the name of your table as
far as Django is concerned. Django will be looking at a table called
'appname_dataset'.

If you actually want Django to look in the 'dataset' table, rather
than the name Django creates, look in the Django docs for the Model
Meta option 'db_table'.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms edit_inline formsets

2007-09-06 Thread Russell Keith-Magee

On 9/6/07, patrickk <[EMAIL PROTECTED]> wrote:
>
> I´m having 2 models, where one is edited inline.
> Now, I have to make some customization to the admins add- and change-
> form (view and template).
>
> Question is: Should I go for formsets.py in the newadmin-branch or is
> there another (maybe easier) possibility?
> If I should use formsets.py, does anyone have an example on how to use
> it?

Depends a little on how adventurous you are feeling. Your options are:
- Manually roll out the whole form
- Hand write a form generating mechanism that works for your model
- Try to work out how to use formsets.

I'm using formsets on a project at work, and haven't had any major
problems, so the third option is definitely viable.

However, there isn't much by way of helpful documentation or examples.
At this point, the best documentation is the test code and the way
newforms-admin uses formsets.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding field to model

2007-09-06 Thread KpoH

alter table your_table add column blablalbla

ksuess пишет:
> hi. I had to add a field to an existing model. how do i update the db?
> (of course there is content.)
>   

-- 
Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L.
http://www.asterisksupport.ru
http://www.asterisk-support.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problems with finnish after upgrading to latest svn head

2007-09-06 Thread Kenneth Gonsalves


On 06-Sep-07, at 4:27 PM, Chris Hoeppner wrote:

> Make sure you're serving the content with the right content type in
> HTML, and that Django is working with the right content type, and that
> the files have a coding declared.

all this is correctly done - it was working before I upgraded to svn  
trunk (i was working in non-unicode previously, and am in unicode now.
>
> El jue, 06-09-2007 a las 16:24 +0530, Kenneth Gonsalves escribió:
>> hi,
>> I have a site in finnish. It was rendering fine until I upgraded to
>> the latest svn head. Now the character A with marks on top of it
>> refuses to render. The other finnish characters are rendering. Any
>> clues?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need help for transaction with postGreSql....

2007-09-06 Thread Andrey Khavryuchenko


 s> I just wanna know how  to do the  trasnsaction with postgresql. If
 s> anyone has any clue / document, or has some working code on this
 s> issue, just send me the related excerpts.

Quick google search on "django transaction" reveals

http://www.djangoproject.com/documentation/transactions/

-- 
Andrey V Khavryuchenko
Django NewGate -  http://www.kds.com.ua/djiggit/
Development - http://www.kds.com.ua 
Call akhavr1975 on www.gizmoproject.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problems with finnish after upgrading to latest svn head

2007-09-06 Thread Chris Hoeppner

Make sure you're serving the content with the right content type in
HTML, and that Django is working with the right content type, and that
the files have a coding declared.

El jue, 06-09-2007 a las 16:24 +0530, Kenneth Gonsalves escribió:
> hi,
> I have a site in finnish. It was rendering fine until I upgraded to  
> the latest svn head. Now the character A with marks on top of it  
> refuses to render. The other finnish characters are rendering. Any  
> clues?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Import error in django

2007-09-06 Thread Karen Tracey
On 9/5/07, AniNair <[EMAIL PROTECTED]> wrote:
>
> Hi... I am using python 2.5.1 with django .97 pre. I am trying to have
> a page from the url config
> (r'^users/', include('dbp.users.views.show')),


The include() around 'dbp.users.views.show' is telling Django to load
another urlconf  module named 'dbp.users.views.show' to further refine how
URLs that start off "users/" should be handled.  But this is apparently not
what you want -- you just want it to call the function show.  Removing the
enclosing include() will get rid of the import error and your show function
should be called.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problems with finnish after upgrading to latest svn head

2007-09-06 Thread Kenneth Gonsalves

hi,
I have a site in finnish. It was rendering fine until I upgraded to  
the latest svn head. Now the character A with marks on top of it  
refuses to render. The other finnish characters are rendering. Any  
clues?
-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



adding field to model

2007-09-06 Thread ksuess

hi. I had to add a field to an existing model. how do i update the db?
(of course there is content.)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Apache + Django - syntax error

2007-09-06 Thread David Reynolds


On 6 Sep 2007, at 11:06 am, b3n wrote:

> I wasn't sure if the syntax was different for Unix/Windows. I think it
> would be helpful if the tutorial made a statement to that effect.

Surely not saying anything implies that there are no differences  
between the two?

-- 
David Reynolds
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with Mysql database

2007-09-06 Thread Nader

For a project the setting of database in 'settings.py' file is as :

DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'ipdc'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = '/path/mysql-data/mysql.sock'
DATABASE_PORT = ''

I can directly get information from mysql session :

mysql> select datasetname from  dataset;
++
| datasetname  |
++
| GOME Level 0 EGOI  |
| GOME Level 1 GDP   |
| GOME Level 2 GDP   |
| GOME2 Level 1a   |
| GOME2 Level 1b   |
++

But if I want to get  information of the same dataset I got the empty
list:

>>> from ipdc.dataset.models import Dataset
>>> Dataset.objects.all()
[]

What is actually here wrong? Have I got forgotten something?
Would somebody tell me how I can solve this problem?

With regards,
Nader


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Apache + Django - syntax error

2007-09-06 Thread b3n

I wasn't sure if the syntax was different for Unix/Windows. I think it
would be helpful if the tutorial made a statement to that effect.


On 29 Aug, 23:39, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> On Aug 29, 11:06 pm, b3n <[EMAIL PROTECTED]> wrote:
>
> > Hey I managed to get Apache to find Django!
>
> > 
> > SetHandler python-program
> > PythonHandler django.core.handlers.modpython
> > PythonPath "['C:\Python'] + sys.path"
> > SetEnv DJANGO_SETTINGS_MODULE bookmarks.settings
> > PythonDebug On
> > 
>
> > Now I get a nice Django-styled error instead of the crappymod_python
> > one ;)
>
> And to make it clear to others what the problem was, you weren't
> setting PythonPath correctly as per the documentation. Ie., you were
> missing the fact that you had to add to sys.path and not replace it.
>
> Graham


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



newforms edit_inline formsets

2007-09-06 Thread patrickk

I´m having 2 models, where one is edited inline.
Now, I have to make some customization to the admins add- and change-
form (view and template).

Question is: Should I go for formsets.py in the newadmin-branch or is
there another (maybe easier) possibility?
If I should use formsets.py, does anyone have an example on how to use
it?

Below are the models (don´t know if that information is necessary
though).

Thanks,
Patrick

class CinemaProgram(models.Model):
"""
Kinoprogramm - Verknüpfung von Kino, Film und evt.
Spezialprogramm.
"""
from www.festivals.models import SpecialScreening

cinema = models.ForeignKey(Cinema, verbose_name="Kino")
movie = models.ForeignKey(Movie, raw_id_admin=True,
verbose_name="Film")
specialscreening = models.ForeignKey(SpecialScreening,
raw_id_admin=True, blank=True, null=True,
related_name="rel_specialscreening", verbose_name="Spezialprogramm")
# Additionals
add_info = models.CharField('Zusatzinfo', maxlength=100,
blank=True, null=True)
# Manager
objects = DateManager()

class Meta:
verbose_name = "Kinoprogramm"
verbose_name_plural = "Kinoprogramme"
ordering = ['cinema', 'movie']

class Admin:
list_display = ('id', 'cinema', 'movie', 'specialscreening',)
list_display_links = ('cinema',)
list_filter = ('cinema',)

def __unicode__(self):
return u"%s" % (self.movie.title)


class CinemaProgramDate(models.Model):
"""
Kinoprogramm - Beginnzeiten und Saalinformation.
"""

cinemaprogram = models.ForeignKey(CinemaProgram,
edit_inline=models.TABULAR, num_in_admin=20, max_num_in_admin=200,
num_extra_on_change=20)
# Date/Time
screening_date = models.DateField('Datum', core=True)
screening_time = models.TimeField('Beginnzeit', core=True)
# Additionals
add_screen = models.CharField('Saal', maxlength=50)
add_info = models.CharField('Zusatzinfo', maxlength=100,
blank=True, null=True)
add_version = models.ForeignKey(Version, blank=True, null=True,
verbose_name="Version")

class Meta:
verbose_name = "Kinoprogramm (Zeiten)"
verbose_name_plural = "Kinoprogramme (Zeiten)"
ordering = ['add_screen', 'screening_date', 'screening_time']

class Admin:
list_display = ('cinemaprogram', 'screening_date',
'screening_time', 'add_version',)

def __unicode__(self):
return u"%s %s" % (self.screening_date, self.screening_time)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Q lookup with both OR and AND

2007-09-06 Thread Michael Radziej

On Thu, Sep 06, [EMAIL PROTECTED] wrote:

> I thought I was close with this, but it only returned tickets assigned
> to me. (The parenthesis around the 2nd and 3rd Q's obviously didn't
> help)
> 
> Ticket.objects.filter(Q(private__exact=False) |
> (Q(private__exact=True) & Q(assigned_user__username__exact='snewman')))

Well, that's a known bug. Django uses inner joins even when combining
queries. A refactoring of the ORM is on the way, in the mean time you could
only either write custom SQL or resort to multiple queries.

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Hierarchical menus

2007-09-06 Thread MikeHowarth

Chris

Thanks for the plug!

Reading through that code makes it much clearer and gives me a great
example to follow. I've been thinking about looking at satchmo you
could just have another convert!

cheers

Mike

On Sep 5, 9:21 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote:
> I've used satchmo before as an example but here it is again.
>
> Here is the model that describes the 
> category-http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/prod...
>
> Here is the template to display the 
> menu-http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/temp...
>
> This template tag does all of the hard 
> work-http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/shop...
>
> Hope this helps.
>
> -Chris


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to implement 3X2 lines?

2007-09-06 Thread [EMAIL PROTECTED]

sorry, i am a newbie to python.
i have a queryset with 6 record, i want to show in 3 col and 2 row,
how to do this, 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: jellyroll app update.py

2007-09-06 Thread nostalgicapathy

Chris,

In re: this:
> In addition, there doesn't seem to be much documnetation on how to set
> JELLYROLL_PROVIDERS in settings.py and where to set username &
> passwords for services.

at least for the delicious portion of the app you would add the
following to your settings.py file.  It can go anywhere in the file,
but I have a section for Jellyroll usernames and passwords.

DELICIOUS_USERNAME=username
DELICIOUS_PASSWORD=password

once you have that in settings you should be able to go.

Hope this helps.

Kit


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---