Re: django-admin.py cleanup large scale

2010-08-20 Thread Steve Holden
On 8/20/2010 9:44 PM, Russell Keith-Magee wrote:
> On Fri, Aug 20, 2010 at 11:51 PM, bfrederi  wrote:
>> I just wanted to know if anyone had an opinion or whether running a
>> django-admin.py cleanup on 40 million session rows might slow down or
>> lock up the database. I would like to do this cleanup ASAP, but I was
>> concerned it might cause some issues.
> 
> It depends entirely on your database. If you're using MySQL with
> MyISAM tables, then almost certainly yes due to the table-level
> locking. Other databases may be affected for different reasons.
> 
> If you're trying to evaluate the risk, the cleanup command executes
> the following:
> 
> Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
> 
> Which is the SQL equivalent of:
> 
> DELETE FROM django_session WHERE expire_date > '2010-01-01 1:23:45';
> 
> inside a the default transaction mode for your database. You'll have
> to consult your database documentation to establish whether that will
> pose a locking risk.
> 
> Yours,
> Russ Magee %-)
> 
Alternatively you could choose to delete these rows without using the
cleanup function. This would allow you to delete them in chunks small
enough to have much lower impact on the database.

regards
 Steve

-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-20 Thread Russell Keith-Magee
On Sat, Aug 21, 2010 at 8:09 AM, Andy  wrote:
>

> So is there any way to write the database router to route the above
> query?

Other than explicitly naming the database -- not at present.

Of course, given that you know your sharding scheme, you could use the
router directly.

Tweet.objects.using(router.db_for_read(Tweet, author=a)).filter(author_id=a)

This will use the router to determine the right database, based upon a
custom 'author' hint. It will require a bit of extra logic in your
router, and a little extra work whenever you use the Tweet object.,
but it will ensure your routing logic is used consistently.

>> If you think that Django isn't providing
>> sufficient information to implement a specific routing scheme, make
>> your case and we will see about adding whatever extra information may
>> be required.
>
> The issue with using only "instance" as a hint is that in almost all
> cases of database reads there isn't any instance to speak of at the
> time the query is being issued. After all the very purpose of a
> database read is to retrieve the instance!

No - the purposes of a database read is to issue queries, which may
represent an instance, or many instances, or selected columns from one
or many instances, or aggregated data across instances.

The filter clause *might* include the argument being used as a
sharding deteminant, or it might not; it might be a simple equality
query, or it might be a gt/lt/not clause; and the sharding behavior
that is implemented may be based on a combination of multiple factors,
rather than a single field value.

As always, the devil is in the detail.

> The above example of:
> Tweet.objects.filter(author_id=123)
> represents pretty much the most common scenario for database sharding.
> I'd think it's important for Django's multidatabase function to be
> able to handle a case like that.

You won't get any argument from me. What's missing is a clear
suggestion on how we can encompass this problem in the general case.
Suggestions are 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin.py cleanup large scale

2010-08-20 Thread Russell Keith-Magee
On Fri, Aug 20, 2010 at 11:51 PM, bfrederi  wrote:
> I just wanted to know if anyone had an opinion or whether running a
> django-admin.py cleanup on 40 million session rows might slow down or
> lock up the database. I would like to do this cleanup ASAP, but I was
> concerned it might cause some issues.

It depends entirely on your database. If you're using MySQL with
MyISAM tables, then almost certainly yes due to the table-level
locking. Other databases may be affected for different reasons.

If you're trying to evaluate the risk, the cleanup command executes
the following:

Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()

Which is the SQL equivalent of:

DELETE FROM django_session WHERE expire_date > '2010-01-01 1:23:45';

inside a the default transaction mode for your database. You'll have
to consult your database documentation to establish whether that will
pose a locking risk.

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



Re: searching stackedinline fields via search_fields in admin

2010-08-20 Thread Karen Tracey
On Fri, Aug 20, 2010 at 4:54 PM, ringemup  wrote:

> The admin search isn't searching the ModelAdmin or Inline files, it's
> searching the fields from the model.
>
> You can search a ForeignKey's fields by listing
> 'foreignkeyfieldname__relatedmodelfieldname' in your search_fields.
> So for example if you had the following models:
>
> class Author(models.Model):
>...
>lastname = models.CharField(max_length=50)
>
>
> class Book(models.Model):
>...
>title = models.CharField(max_length=50)
>author = models.ForeignKey(Author, related_name='works')
>
>
> Then you could do the following in your admin:
>
> class BookAdmin(admin.ModelAdmin):
>model = Book
>search_fields = ['title', 'author__lastname', ...]
>
>
>
> However, I'm not sure you can do the reverse:
>
> class AuthorAdmin(admin.ModelAdmin):
>model = Author
>search_fields = ['lastname', 'works__title']
>

Yes, you can.

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

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



Re: debug=True changes behavior of admin "fields"

2010-08-20 Thread Ramiro Morales
On Tue, Aug 17, 2010 at 1:34 AM, Jerry Stratton  wrote:
> On Aug 16, 3:43 pm, Karen Tracey  wrote:
>> So yes, the ImproperlyConfigured error is something you will only get with
>> DEBUG on. But I would expect that the effect of the problem it identified
>> would be seen at some point when you try using the admin with DEBUG off.
>> That is, I'd expect you to hit some (possibly pretty cryptic) error at some
>> point, or find that not all the fields you are expecting are actually
>> listed, or something like that.
>
> In this case all four were displayed, in the order listed, and with
> the top two (title and category) grouped on the same line. I was able
> to add and edit several entries, until I started adding functionality
> that required me to turn DEBUG on and got that error. (I had hoped to
> use the simpler format so that it would be easier for our less Python-
> savvy team members to understand.)

I was going to point to the 'fields' documentation, which don't talk at
all being able to accept the nested tuples like the 'fields' option
inside 'fieldsets' elements does.

Then went to the admin source code and saw that the implementation of
'fields' defers to the 'fieldsets' one simply specifying a None in the
fieldset name and obviating any other option ('classes', 'description').

That explains why it works for you with DEBUG=False.

The obvious next step was to see how to remove the offending validation
code Karen described. Fortunately there is some duplicated code in that
zone that can be factored out. This means the feature you are using
could be officially added by removing code instead of adding it, plus
tests and documentation.

I've put a patch for this at [1]. Will try to get Django devs opinions
about if this is worth and open a ticket if so.

-- 
Ramiro Morales  |  http://rmorales.net

1. http://paste.pocoo.org/show/252613/

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



Re: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-20 Thread Andy


On Aug 19, 9:03 pm, Russell Keith-Magee 
wrote:

> As for the instance not existing: Consider the following queries:
>
> MyModel.objects.filter(foo=bar)
>
> or
>
> MyModel.objects.update(foo=bar)
>
> These are read and write queries respectively, but neither has any
> meaningful concept of a current "instance".

OK, now I see the issue.

I'd need to do queries like this one:

Tweet.objects.filter(author_id=123)

Now like you said there isn't any current instance to speak of.
However since I'm retrieving tweets from a specific author it is very
clear which shard this query should go to as tweets are sharded by
author_id.

So is there any way to write the database router to route the above
query?


> If you think that Django isn't providing
> sufficient information to implement a specific routing scheme, make
> your case and we will see about adding whatever extra information may
> be required.

The issue with using only "instance" as a hint is that in almost all
cases of database reads there isn't any instance to speak of at the
time the query is being issued. After all the very purpose of a
database read is to retrieve the instance!

The above example of:
Tweet.objects.filter(author_id=123)
represents pretty much the most common scenario for database sharding.
I'd think it's important for Django's multidatabase function to be
able to handle a case like that.

Thanks.

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



model validation with admin.TabularInline

2010-08-20 Thread bagheera


Take a look into pool app from django tutorial. How can i make validation  
of Question model to have at least two Answer entered, if  
admin.TabularInline is used?


http://docs.djangoproject.com/en/1.2/intro/tutorial02/#adding-related-objects

--
Linux user

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



Re: jsonrpclib 403 error

2010-08-20 Thread adrian.w...@gmail.com
Hi Jani

Thanks for the reply.  My real aim was to get the Pyjamas examples
working specifically the Jsonrpc example.  The reason for the 403
error is that I am using Django version 1.2 which includes csrf,
however I don't know how to get Pyjamas to generate the token from a
manually created form such as that in the JSON-RPC Example.

To work around this for now I have disabled the csrf middleware
settings in settings.py and the applications now work, however this
would not be a long term solution.

If anybody has any thoughts on this then they would be really
appreicated.



On Aug 20, 12:56 pm, Jani Tiainen  wrote:
> > I have python 2.5.4 installed along with Django-1.2.1 and am trying to
> > test jsonrpc using jsonrpclib.  I have been following the Pyjamas
> > tutorial and have got to the point where Django is introduced.
>
> > I have tried numerous different things but everything I try results in
> > a 403 error. I have taken apache out of the equation and am just using
> > the django developmemt web server but the problem is the same.
>
> > Any help would be appreciated.
>
> I'm not using rpclib just because it felt somewhat hard to use with Django.
> Instead of that I've been using my own solution for that:
>
> http://drpinkpony.wordpress.com/2010/01/12/django-json-rpc-service/
>
> It works pretty nicely with Dojotoolkit at least, and it's been battle tested
> now in production environments.
>
> --
>
> Jani Tiainen

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



Re: Path mess

2010-08-20 Thread Shawn Milochik
If you set your environment variable DJANGO_SETTINGS_MODULE in the
environment your script is running in, you need only add this line to
your script (in addition to your model imports, of course).

from django.conf import settings

Otherwise you'll need to import the OS module in your script and add a
line like this:

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

Note that, in either case, you need to ensure that the proper path has
been added to your PYTHONPATH.

More detail, since you said you weren't quite a Python pro yet.

Prerequisite

Ensure that your project folder is on your PYTHONPATH.
Example:

#at the command line, not in your script
export PYTHONPATH=/home/name/projects:$PYTHONPATH

Solution #1:
#at the command line, not in your script
export DJANGO_SETTINGS_MODULE='myproject.settings'

Now you can just do this in your script:
from django.conf import settings

Solution #2:

#in your script, not on the command line
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

To me, solution 1 is easier, and cleaner, because if you change your
settings file you don't have to change all your scripts. However, you
may not have the ability to change the environment if you have
multiple Django projects and don't want to break all the other ones.

Shawn

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



Re: Path mess

2010-08-20 Thread ringemup

You need your external program to do several things:

1) make sure django is on your PYTHONPATH (or within the Python
script, on sys.path)
2) make sure your apps are also on the PYTHONPATH (or sys.path)
3) set the DJANGO_SETTINGS_MODULE environment variable in your shell
or script

Then you just import the same way you would in Django itself:

from appname.models import MyModel




On Aug 20, 3:03 pm, clochemer  wrote:
> Hi everyone!
>
> It's my first question, and that's because I am totally lost. I am not
> a great Django developer (neither a good Python programmer) so I do
> not even know if I am doing the right things, let me explain...
>
> I have an external Python program which reads from a socket and
> depending on what it receives, it inserts some new models in Django
> database. All clear right here?
>
> Let's go on... I said myself "Hey genius, you only have to import the
> models and that's all!". So I made a new folder on my project path
> called utils, so I have something like... /home/myproject/utils/
> communicator.py, where my fantastic program is located.
>
> But as all of you might have already seen, i don't know how to import
> models form there.
>
> I had a problem similar, as i defined some Python functions which deal
> with models and are used in several Django applications, but i solved
> it by locating those functions in /usr/lib/python2.6/site-packages/
> django/contrib/myproject and the import worked. I guess the problem is
> in a Python/Django paths misunderstanding of mine.
>
> I need some wisdom & guidance,
>
> Thanks!

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



Re: searching stackedinline fields via search_fields in admin

2010-08-20 Thread ringemup

The admin search isn't searching the ModelAdmin or Inline files, it's
searching the fields from the model.

You can search a ForeignKey's fields by listing
'foreignkeyfieldname__relatedmodelfieldname' in your search_fields.
So for example if you had the following models:

class Author(models.Model):
...
lastname = models.CharField(max_length=50)


class Book(models.Model):
...
title = models.CharField(max_length=50)
author = models.ForeignKey(Author, related_name='works')


Then you could do the following in your admin:

class BookAdmin(admin.ModelAdmin):
model = Book
search_fields = ['title', 'author__lastname', ...]



However, I'm not sure you can do the reverse:

class AuthorAdmin(admin.ModelAdmin):
model = Author
search_fields = ['lastname', 'works__title']




On Aug 20, 4:45 pm, gondor  wrote:
> Hello All,
>
> I'm wanting to add a field from my stackedinline form to my
> search_fields in admin.  Does anyone know how to do that or point me
> in a general direction/sample code?
>
> Thanx
> Condor

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



searching stackedinline fields via search_fields in admin

2010-08-20 Thread gondor
Hello All,

I'm wanting to add a field from my stackedinline form to my
search_fields in admin.  Does anyone know how to do that or point me
in a general direction/sample code?

Thanx
Condor

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



Re: __init__() got an unexpected keyword argument 'core'

2010-08-20 Thread Pankaj Singh
I am using django 1.2.1


-- 
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
3rd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur
Website - http://www.IamPankaj.in 
Email - cont...@iampankaj.in , singh.pankaj.iitkg...@gmail.com
Mobile - (+91) 8001231685

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



Path mess

2010-08-20 Thread clochemer
Hi everyone!

It's my first question, and that's because I am totally lost. I am not
a great Django developer (neither a good Python programmer) so I do
not even know if I am doing the right things, let me explain...

I have an external Python program which reads from a socket and
depending on what it receives, it inserts some new models in Django
database. All clear right here?

Let's go on... I said myself "Hey genius, you only have to import the
models and that's all!". So I made a new folder on my project path
called utils, so I have something like... /home/myproject/utils/
communicator.py, where my fantastic program is located.

But as all of you might have already seen, i don't know how to import
models form there.

I had a problem similar, as i defined some Python functions which deal
with models and are used in several Django applications, but i solved
it by locating those functions in /usr/lib/python2.6/site-packages/
django/contrib/myproject and the import worked. I guess the problem is
in a Python/Django paths misunderstanding of mine.

I need some wisdom & guidance,

Thanks!

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



Re: deserializing json

2010-08-20 Thread Reinout van Rees

On 08/20/2010 02:16 PM, irum wrote:

Hi,
I am trying to parse json, loop through it and access its data.
At first I tried this:

for obj in serializers.deserialize("json", p):
 a=2
 response = HttpResponse()
 response.status_code = 200
 return response


One small thing to try:
response = HttpResponse('')
instead of:
response = HttpResponse()

So: feed it an empty string.

As it complains about being unreadable, perhaps you should stuff 
something into it.  Just a pretty wild guess...




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

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



Using all project URLs when using TestCase.urls?

2010-08-20 Thread Bryan
I've been trying to add the django-lean app to my project.

I have not been able to get the tests to pass because of
NoReverseMatch errors for named urls defined in other apps.

It seems the issue is that the TestCase defines a value for urls:

 urls = 'django_lean.experiments.tests.urls'

As best as I can tell, the tests are only getting the urls located @
'django_lean.experiments.tests.urls', but not
the urls from the rest of the project.

This is causing error messages like:

NoReverseMatch: Reverse for 'index' with arguments '()' and
keyword arguments '{}' not found.

These are triggered by {% url %} template tags in the project.

How can I make sure that the all the urls of the project are available
for the tests?

I'm running Python 2.7 with Django 1.2.1

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



Re: __init__() got an unexpected keyword argument 'core'

2010-08-20 Thread Rolando Espinoza La Fuente
On Fri, Aug 20, 2010 at 12:40 PM, Pankaj Singh
 wrote:
> I am gettign this error but as per documentation
> http://www.djangoproject.com/documentation/0.96/model-api/#core this should
> not be a problem
>
> http://code.google.com/p/django-openid-auth/source/browse/trunk/openid_auth/models.py

Are you using django 0.96?

The latest is 1.2.1, but django-openid-auth seems old too.

Rolando Espinoza La fuente
www.insophia.com


> pan...@pankaj-laptop:~/django_projects/mysite$ ./manage.py syncdb
> Traceback (most recent call last):
>   File "./manage.py", line 13, in 
>     execute_manager(settings)
>   File
> "/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
> line 438, in execute_manager
>     utility.execute()
>   File
> "/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
> line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
> line 191, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
> line 217, in execute
>     self.validate()
>   File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
> line 245, in validate
>     num_errors = get_validation_errors(s, app)
>   File
> "/home/pankaj/django_projects/mysite/django/core/management/validation.py",
> line 28, in get_validation_errors
>     for (app_name, error) in get_app_errors().items():
>   File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
> line 146, in get_app_errors
>     self._populate()
>   File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
> line 61, in _populate
>     self.load_app(app_name, True)
>   File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
> line 78, in load_app
>     models = import_module('.models', app_name)
>   File "/home/pankaj/django_projects/mysite/django/utils/importlib.py", line
> 35, in import_module
>     __import__(name)
>   File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 10,
> in 
>     class UserOpenID(models.Model):
>   File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 14,
> in UserOpenID
>     user = models.ForeignKey(User, core=True, related_name="openids")
>   File
> "/home/pankaj/django_projects/mysite/django/db/models/fields/related.py",
> line 820, in __init__
>     Field.__init__(self, **kwargs)
> TypeError: __init__() got an unexpected keyword argument 'core'
>
>
> --
> --
> --
> --
> Thanking You,
>
> Pankaj Kumar Singh,
> 3rd Year Undergraduate Student,
> Department of Agricultural and Food Engineering,
> Indian Institute of Technology,
> Kharagpur
> Website - http://www.IamPankaj.in
> Email - cont...@iampankaj.in , singh.pankaj.iitkg...@gmail.com
> Mobile - (+91) 8001231685
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



__init__() got an unexpected keyword argument 'core'

2010-08-20 Thread Pankaj Singh
I am gettign this error but as per documentation
http://www.djangoproject.com/documentation/0.96/model-api/#core this should
not be a problem

http://code.google.com/p/django-openid-auth/source/browse/trunk/openid_auth/models.py

pan...@pankaj-laptop:~/django_projects/mysite$ ./manage.py syncdb
Traceback (most recent call last):
  File "./manage.py", line 13, in 
execute_manager(settings)
  File
"/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
line 438, in execute_manager
utility.execute()
  File
"/home/pankaj/django_projects/mysite/django/core/management/__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 217, in execute
self.validate()
  File "/home/pankaj/django_projects/mysite/django/core/management/base.py",
line 245, in validate
num_errors = get_validation_errors(s, app)
  File
"/home/pankaj/django_projects/mysite/django/core/management/validation.py",
line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 146, in get_app_errors
self._populate()
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 61, in _populate
self.load_app(app_name, True)
  File "/home/pankaj/django_projects/mysite/django/db/models/loading.py",
line 78, in load_app
models = import_module('.models', app_name)
  File "/home/pankaj/django_projects/mysite/django/utils/importlib.py", line
35, in import_module
__import__(name)
  File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 10,
in 
class UserOpenID(models.Model):
  File "/home/pankaj/django_projects/mysite/openid_auth/models.py", line 14,
in UserOpenID
user = models.ForeignKey(User, core=True, related_name="openids")
  File
"/home/pankaj/django_projects/mysite/django/db/models/fields/related.py",
line 820, in __init__
Field.__init__(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'core'


-- 
-- 
-- 
--
Thanking You,

Pankaj Kumar Singh,
3rd Year Undergraduate Student,
Department of Agricultural and Food Engineering,
Indian Institute of Technology,
Kharagpur
Website - http://www.IamPankaj.in 
Email - cont...@iampankaj.in , singh.pankaj.iitkg...@gmail.com
Mobile - (+91) 8001231685

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



Stockphoto

2010-08-20 Thread John S. Dey
Hi,

I am new to django.  The stockphoto app interested my but I have discovered 
that it is not current.  I am working my way through it to upgrade--models seem 
to work but the forms in view still need updating.

Has anyone updated the app?  And if so, would you share with me.  Thanks.

John

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



django-admin.py cleanup large scale

2010-08-20 Thread bfrederi
I just wanted to know if anyone had an opinion or whether running a
django-admin.py cleanup on 40 million session rows might slow down or
lock up the database. I would like to do this cleanup ASAP, but I was
concerned it might cause some issues.

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



Re: Newbie question about url and seo

2010-08-20 Thread Karim Gorjux
On Fri, Aug 20, 2010 at 18:19, David Euzen  wrote:
> Hello,
>
> you should think of it in terms of ressource, not of file. URLs are
> about ressources not about files even if sometimes ressources are
> files.

Thanks for your answer. Was very useful!

Have a nice day.

-- 
Karim Gojux
www.karimblog.net

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



Re: Validation error messages without post

2010-08-20 Thread JP
Here is my form code as well:
from django import forms
from django.contrib.auth.models import User
from djangoproject1.authentication.models import UserProfile

class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('username','password','email',)

class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('phonenumber',)

On Aug 20, 11:05 am, JP  wrote:
> My main page contains a form.  Because I want the form to appear when
> I load my page my view looks like this:
>
> from djangoproject1.authentication import forms
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response
>
> def main(request):
>     uf = forms.UserForm()
>     upf = forms.UserProfileForm()
>     return render_to_response("authentication/index.html", {'form1':
> uf, 'form2':upf})
>
> def register(request):
>     if request.method == 'POST':
>         uf = forms.UserForm(request.POST)
>         upf = forms.UserProfileForm(request.POST)
>         if uf.is_valid() and upf.is_valid():
>             user = uf.save(commit=False)
>             user.set_password(uf.cleaned_data["password"])
>             user.save()
>             userprofile = upf.save(commit=False)
>             userprofile.user = user
>             userprofile.save()
>             return HttpResponseRedirect("/register-success/")
>     return render_to_response("authentication/index.html", {'form1':
> uf,'form2':upf})
>
> When I visit the main page, my URLConf points me to main.  If I were
> to hit submit, I would be directed to register.  The problem is, when
> I visit the page, all of the validation error messages for my fields
> are already shown for username and password.
>
> Here's my html:
>
> Register
>     
>         {{ form1.as_p }}
>         {{ form2.as_p }}
>         
>     
>
> Thanks

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



Re: Newbie question about url and seo

2010-08-20 Thread David Euzen
Hello,

you should think of it in terms of ressource, not of file. URLs are
about ressources not about files even if sometimes ressources are
files.

Django's way to build URLs is flexible. URLs built this way can make
much more sense that URLs built upon file path. ie
www.yourdomain.com/articles/20101/08/20/your_article_title is way
clearer than www.yourdomain.com/article.php?id=15820

Web crawlers collect URLs, I think they don't bother wether URL
contains a file path or not (but I'm not a expert on this topic). And
the more the URL is clear, the best the ressource is ranked.
I've read many times about clear URLs in SEO good practices.

On 20 août, 14:02, Karim Gorjux  wrote:
> Hi all! This is my first post here in the list, I'm new in django and
> python but I really found it fun and exciting so here we are!
> My first question is pretty simple. I noted that the url I create
> using urls.py are cleaned and pretty but there is no index.html or
> simila. It seems that every url point to a directory. Is that good in
> terms of SEO?
>
> I guess that is even better than the old fashion way with the
> index.something, but I don't know.
>
> Thanks in advance
>
> --
> Karim Gojuxwww.karimblog.net

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



Validation error messages without post

2010-08-20 Thread JP
My main page contains a form.  Because I want the form to appear when
I load my page my view looks like this:

from djangoproject1.authentication import forms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response

def main(request):
uf = forms.UserForm()
upf = forms.UserProfileForm()
return render_to_response("authentication/index.html", {'form1':
uf, 'form2':upf})

def register(request):
if request.method == 'POST':
uf = forms.UserForm(request.POST)
upf = forms.UserProfileForm(request.POST)
if uf.is_valid() and upf.is_valid():
user = uf.save(commit=False)
user.set_password(uf.cleaned_data["password"])
user.save()
userprofile = upf.save(commit=False)
userprofile.user = user
userprofile.save()
return HttpResponseRedirect("/register-success/")
return render_to_response("authentication/index.html", {'form1':
uf,'form2':upf})

When I visit the main page, my URLConf points me to main.  If I were
to hit submit, I would be directed to register.  The problem is, when
I visit the page, all of the validation error messages for my fields
are already shown for username and password.

Here's my html:

Register

{{ form1.as_p }}
{{ form2.as_p }}



Thanks

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



Re: deserializing json

2010-08-20 Thread Bill Freeman
Have you tried looking at the raw data to see if it is what you
expect (capture to a file or pdb.set_trace() is your friend)?

Have you tried (assuming relatively recent python, >= 2.6
I think) loads from the json module?

Bill

On Fri, Aug 20, 2010 at 8:16 AM, irum  wrote:
> Hi,
> I am trying to parse json, loop through it and access its data.
> At first I tried this:
>
>               for obj in serializers.deserialize("json", p):
>                        a=2
>                response = HttpResponse()
>                response.status_code = 200
>                return response
>
> Here 'p' has the json data returned to me by another view. I have
> validated it in http://www.jsonlint.com/ and it does not have any
> error.
>
> This gave attribute error.
>   AttributeError at /bookings/52/cancel/
>  'HttpResponse' object has no attribute 'read'
>
> The problem I am sure is not in HttpResponse object as it works fine
> when I comment out the line accessing object of deserialized data i.e
> for obj in serializers.deserialize("json", p)
>
> I then tried writing this:
>
>               deserialized = serializers.deserialize("json",
> self.request.raw_post_data)
>               d = list(deserialized)[0].object
>
> and also this:
>
>               deserialized = serializers.deserialize("json",
> self.request.raw_post_data)
>               d = list(deserialized).object
>
> I again get same error. It works fine if the second line: put_bookmark
> = list(deserialized)[0].object , is commented out. But, when I
> uncomment it to access  object of deserialized data I get the same
> error.
>
> After many trial and errors, I am convinced the problem is when I try
> to access object of deserialized data. I also referred to this thread:
> http://groups.google.com/group/django-users/browse_thread/thread/87bd6951b4aebd00/d8e0a547be1583a8?lnk=gst=deserialize#d8e0a547be1583a8
> in the discussion group. In this thread also the problem trickles down
> to access object of deserialzed data but no further solution is
> available.
>
> I don want to use simplejson. Can someone give me a solution to this
> problem and help me fix this.
>
> Thanks,
> Irum
>
>
> I get the attribute error:
> 'HttpResponse' object has no attribute 'read'
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Accessing model field validators from within form template

2010-08-20 Thread omat
Please see below.


> Why do you use MaxLengthValidator instead of max_length property?

max_length does not work for models.TextField


> What are you using those values for? Couldn't it be a possibility to
> use help_text attribute?

It won't be DRY to repeat the value both as a parameter to the
validator and in the help text. I would like to display the max length
value using a generic template.


Cheers,
omat


> On Aug 18, 3:41 pm, omat  wrote:
>
>
>
> > Hi,
>
> > In my generic form template, if a CharField has a max_length
> > attribute, I display that beside the form field:
>
> > {% if field.field.max_length %}
> >     Max. {{ field.field.max_length }} char.
> > {% endif %}
>
> > I want to do the same for TextFields, where max_length is not used,
> > but the max limit is set by a validator like that in the model:
>
> > class Entry(models.Model):
> >     ...
> >     body = models.TextField(validators=[MaxLengthValidator(1000)])
>
> > For ModelForm, is it possible to access the validators' max value from
> > within the templates similar to this:
>
> > {{ field.validators[0].max_length }}
>
> > Cheers,
> > 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



deserializing json

2010-08-20 Thread irum
Hi,
I am trying to parse json, loop through it and access its data.
At first I tried this:

   for obj in serializers.deserialize("json", p):
a=2
response = HttpResponse()
response.status_code = 200
return response

Here 'p' has the json data returned to me by another view. I have
validated it in http://www.jsonlint.com/ and it does not have any
error.

This gave attribute error.
   AttributeError at /bookings/52/cancel/
  'HttpResponse' object has no attribute 'read'

The problem I am sure is not in HttpResponse object as it works fine
when I comment out the line accessing object of deserialized data i.e
for obj in serializers.deserialize("json", p)

I then tried writing this:

   deserialized = serializers.deserialize("json",
self.request.raw_post_data)
   d = list(deserialized)[0].object

and also this:

   deserialized = serializers.deserialize("json",
self.request.raw_post_data)
   d = list(deserialized).object

I again get same error. It works fine if the second line: put_bookmark
= list(deserialized)[0].object , is commented out. But, when I
uncomment it to access  object of deserialized data I get the same
error.

After many trial and errors, I am convinced the problem is when I try
to access object of deserialized data. I also referred to this thread:
http://groups.google.com/group/django-users/browse_thread/thread/87bd6951b4aebd00/d8e0a547be1583a8?lnk=gst=deserialize#d8e0a547be1583a8
in the discussion group. In this thread also the problem trickles down
to access object of deserialzed data but no further solution is
available.

I don want to use simplejson. Can someone give me a solution to this
problem and help me fix this.

Thanks,
Irum


I get the attribute error:
'HttpResponse' object has no attribute 'read'

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



Newbie question about url and seo

2010-08-20 Thread Karim Gorjux
Hi all! This is my first post here in the list, I'm new in django and
python but I really found it fun and exciting so here we are!
My first question is pretty simple. I noted that the url I create
using urls.py are cleaned and pretty but there is no index.html or
simila. It seems that every url point to a directory. Is that good in
terms of SEO?

I guess that is even better than the old fashion way with the
index.something, but I don't know.

Thanks in advance

-- 
Karim Gojux
www.karimblog.net

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



Re: jsonrpclib 403 error

2010-08-20 Thread Jani Tiainen
> I have python 2.5.4 installed along with Django-1.2.1 and am trying to
> test jsonrpc using jsonrpclib.  I have been following the Pyjamas
> tutorial and have got to the point where Django is introduced.
> 
> I have tried numerous different things but everything I try results in
> a 403 error. I have taken apache out of the equation and am just using
> the django developmemt web server but the problem is the same.
> 
> Any help would be appreciated.

I'm not using rpclib just because it felt somewhat hard to use with Django. 
Instead of that I've been using my own solution for that:

http://drpinkpony.wordpress.com/2010/01/12/django-json-rpc-service/

It works pretty nicely with Dojotoolkit at least, and it's been battle tested 
now in production environments.

-- 

Jani Tiainen

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



Re: admin interface titles

2010-08-20 Thread emre can karabacak
Thanks a lot, =)

On 20 Ağustos, 14:37, Steve Holden  wrote:
> On 8/20/2010 4:22 AM, emre can karabacak wrote:> I'm new to django, and 
> apparently django automatically adds an 's' to
> > the ends of category titles i.e. Groups,Users, etc. but I have
> > 'category' and other titles that end with a 'y'. so django turns these
> > into Categorys, etc. how can I fix this? Is there a way to override
> > the function that does this? thank you.
>
> Yes, indeed. When you define your model you have to put a Meta class
> definition inside it. Within this class definition put
>
>         verbose_name_plural = "Categories"
>
> and you should be good to go. See
>
>  http://docs.djangoproject.com/en/dev/ref/models/options/
>
> for more  options.
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

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



Re: admin interface titles

2010-08-20 Thread Steve Holden
On 8/20/2010 4:22 AM, emre can karabacak wrote:
> I'm new to django, and apparently django automatically adds an 's' to
> the ends of category titles i.e. Groups,Users, etc. but I have
> 'category' and other titles that end with a 'y'. so django turns these
> into Categorys, etc. how can I fix this? Is there a way to override
> the function that does this? thank you.
> 
Yes, indeed. When you define your model you have to put a Meta class
definition inside it. Within this class definition put

verbose_name_plural = "Categories"

and you should be good to go. See

  http://docs.djangoproject.com/en/dev/ref/models/options/

for more  options.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



jsonrpclib 403 error

2010-08-20 Thread adrian.w...@gmail.com
I have python 2.5.4 installed along with Django-1.2.1 and am trying to
test jsonrpc using jsonrpclib.  I have been following the Pyjamas
tutorial and have got to the point where Django is introduced.

I have tried numerous different things but everything I try results in
a 403 error. I have taken apache out of the equation and am just using
the django developmemt web server but the problem is the same.

Any help would be appreciated.

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



admin interface titles

2010-08-20 Thread emre can karabacak
I'm new to django, and apparently django automatically adds an 's' to
the ends of category titles i.e. Groups,Users, etc. but I have
'category' and other titles that end with a 'y'. so django turns these
into Categorys, etc. how can I fix this? Is there a way to override
the function that does this? thank you.

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



django-registration0.8 args on /activation/complete/

2010-08-20 Thread Alex
Hi,
Thanks for great package - just stuck now on how to update app
specific user profile on /activate/complete/

Although I have seen the code (re ln 80 in django-registration/
registration/views.py) I don't understand how to write the correct url
pattern and view params to pick up the activated user in my view so as
I can add some app specific data for each user.

In the url pattern I have:

url(r'^accounts/activate/complete/$' ,'myapp.views.profile',
name='registration_activation_complete'),

and in the view I want this sort of thing so as I can complete the
UserProfile(this fails because the request.user is empty):

def profile(request):
new_user = request.user
profile = UserProfile(user= new_user)

and in the model:

class UserProfile(models.Model):
user = models.OneToOneField(User)
st = models.DateTimeField(auto_now_add=True)
...

I think the problem is not understanding what my view receives from
the 'activate' redirect:

   if success_url is None:
to, args, kwargs =
backend.post_activation_redirect(request, account)
return redirect(to, *args, **kwargs)


I have tried setting a username parameter in the url pattern and view
with no success. How should this be done? I need a - oh that's how it
works - moment.

Any help very appreciated.

  Alex


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



Re: return json format

2010-08-20 Thread Torsten Bronger
Hallöchen!

Imad Elharoussi writes:

> I got readystate = 4 but status = 500

Is Django's setting DEBUG=True?  If so, what does the error message
page say?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Re: Bind variables in Oracle backend - how to use them?

2010-08-20 Thread Tim Sawyer
Excellent, thanks Ian.  It works a treat, post updated.

Tim.

> On Aug 19, 11:58 am, Tim Sawyer  wrote:
>> No, I don't think you're mistaken, especially if you want to use hints.
>>
>> I tried this code again today with the django database connection (using
>> 1.2 final), and it didn't work.  This only works with cx_Oracle
>> connections.
>>
>> Seehttp://drumcoder.co.uk/blog/2010/apr/23/output-parameters-cx_oracle-a...
>
> There are several reasons why that snippet doesn't work:
>
> 1) Django cursors don't support passing in the bind parameters in a
> dictionary.  A sequence type is expected.
>
> 2) Django cursors use the '%s' syntax for placeholders, not the ':out'
> syntax.
>
> 3) The oracle backend automatically trims a trailing semi-colon from
> all queries, because its presence causes ordinary queries to fail.  To
> prevent it from being trimmed, add some whitespace after the semi-
> colon, or add a trailing '/' as in sqlplus if you prefer.
>
> Correcting these three issues, the snippet works as expected in 1.2.
>
> On Aug 19, 12:14 pm, buddhasystem  wrote:
>> I'm 90% sure that you can't get the cx cursor out of Django connection.
>> These are similar but different classes. I tried something like that.
>
> It works like this:
>
> from django.db import connection
> django_cursor = connection.cursor()
> cx_cursor = django_cursor.cursor
>
> This is internal API, so it could change in the future.
>
> On Aug 18, 2:58 pm, buddhasystem  wrote:
>> However, both "my" and yours solution suffer from the same defect imho
>> --
>> that the ORM machinery of Django is unusable. We are back to manual
>> mapping
>> of rows onto objects... Or -- am I mistaken?
>
> The raw query mechanism will do the ORM mapping as long as you match
> up the column names correctly when writing the query.  The problem
> with that is that you can't use cursor.var() directly, because you
> don't have direct access to the particular cursor used to run the
> query.
>
> There is some more internal API that may help with this.  You can pass
> in as a bind parameter an object that has a "bind_parameter" method
> with the signature "def bind_parameter(self, cursor)".  When the
> statement is executed, the cursor will call that method, which is
> expected to return the actual bind variable, and substitute the bind
> variable for the object.
>
> For an example, have a look at the "InsertIdVar" class in django/db/
> backends/oracle/base.py, which is used within the "RETURNING INTO"
> clause of an insert statement to receive the primary key of the
> inserted object.
>
> Hope this helps,
> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


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



Re: return json format

2010-08-20 Thread Xavier Ordoquy
Please, it is not the first time we ask you to describe as much as you can if 
you got an issue.
We don't have access to your code and what you do before/after.

Saying just "it doesn't work" could be because:
 - you didn't turn on your computer
 - you didn't started the dev server
and a lot of other useless stupid things.

Try to be more verbose about your problems if you want some support.

Regards,
Xavier.

Le 20 août 2010 à 11:34, Imad Elharoussi a écrit :

> It's not the case for me  !!!
> 
> 2010/8/20 Emily Rodgers 
> On Aug 20, 10:01 am, Imad Elharoussi 
> wrote:
> > Hello
> >
> > How can we return an object in a json format?
> >
> > it is like this :
> >
> > return HttpResponse(simplejson.dumps(ihmAgentRoot),
> > mimetype='application/json')
> >
> > or do we need an other thing?
> >
> > thank you
> 
> That is what I do and it works.
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: return json format

2010-08-20 Thread Imad Elharoussi
I got readystate = 4 but status = 500

2010/8/20 Emily Rodgers 

> What goes wrong?
>
> On Aug 20, 10:34 am, Imad Elharoussi 
> wrote:
> > It's not the case for me  !!!
> >
> > 2010/8/20 Emily Rodgers 
> >
> > > On Aug 20, 10:01 am, Imad Elharoussi 
> > > wrote:
> > > > Hello
> >
> > > > How can we return an object in a json format?
> >
> > > > it is like this :
> >
> > > > return HttpResponse(simplejson.dumps(ihmAgentRoot),
> > > > mimetype='application/json')
> >
> > > > or do we need an other thing?
> >
> > > > thank you
> >
> > > That is what I do and it works.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: return json format

2010-08-20 Thread Emily Rodgers
What goes wrong?

On Aug 20, 10:34 am, Imad Elharoussi 
wrote:
> It's not the case for me  !!!
>
> 2010/8/20 Emily Rodgers 
>
> > On Aug 20, 10:01 am, Imad Elharoussi 
> > wrote:
> > > Hello
>
> > > How can we return an object in a json format?
>
> > > it is like this :
>
> > > return HttpResponse(simplejson.dumps(ihmAgentRoot),
> > >                                     mimetype='application/json')
>
> > > or do we need an other thing?
>
> > > thank you
>
> > That is what I do and it works.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: return json format

2010-08-20 Thread Imad Elharoussi
It's not the case for me  !!!

2010/8/20 Emily Rodgers 

> On Aug 20, 10:01 am, Imad Elharoussi 
> wrote:
> > Hello
> >
> > How can we return an object in a json format?
> >
> > it is like this :
> >
> > return HttpResponse(simplejson.dumps(ihmAgentRoot),
> > mimetype='application/json')
> >
> > or do we need an other thing?
> >
> > thank you
>
> That is what I do and it works.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: return json format

2010-08-20 Thread Emily Rodgers
On Aug 20, 10:01 am, Imad Elharoussi 
wrote:
> Hello
>
> How can we return an object in a json format?
>
> it is like this :
>
> return HttpResponse(simplejson.dumps(ihmAgentRoot),
>                                     mimetype='application/json')
>
> or do we need an other thing?
>
> thank you

That is what I do and it works.

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



return json format

2010-08-20 Thread Imad Elharoussi
Hello

How can we return an object in a json format?

it is like this :

return HttpResponse(simplejson.dumps(ihmAgentRoot),
mimetype='application/json')

or do we need an other thing?

thank you

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



Re: Displaying images

2010-08-20 Thread Ivan
Do you write your own context processors?

If yes, you need to add 'django.core.context_processors.media' in
TEMPLATE_CONTEXT_PROCESSORS manually.

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.media',
)

Cheers,
Ivan



On Fri, Aug 20, 2010 at 4:07 AM, Greg Pelly  wrote:
> Are your settings properly set up? Can you confirm that you are able to
> print settings.MEDIA_URL in your view?  MEDIA_URL defaults to the empty
> string, so that seems like the problem.  Then, pass in the request context
> as I described previously.
> From http://docs.djangoproject.com/en/dev/ref/templates/api/
> If TEMPLATE_CONTEXT_PROCESSORS contains this processor, every RequestContext
> will contain a variable MEDIA_URL, providing the value of the MEDIA_URL
> setting.
>
> Greg
>
> On Thu, Aug 19, 2010 at 10:54 AM, Bradley Hintze
>  wrote:
>>
>> Greg, that didn't do it :(
>> Thanks though :)
>>
>> On Thu, Aug 19, 2010 at 1:43 PM, Greg Pelly  wrote:
>> > try this:
>> > def math_form(request):
>> >   return render_to_response('form.html',
>> > {}, context_instance=RequestContext(request))
>> >
>> > greg
>> > On Thu, Aug 19, 2010 at 10:35 AM, Bradley Hintze
>> >  wrote:
>> >>
>> >> I am sorry. I am using render to response.
>> >>
>> >>  #view.py
>> >>
>> >> def math_form(request):
>> >>    return render_to_response('form.html')
>> >>
>> >> #base.html
>> >>
>> >> 
>> >> 
>> >> 
>> >>    {% block title %}{% endblock %}
>> >> 
>> >> 
>> >> 
>> >>    {% block header %}{% endblock %}
>> >>    Please enter two numbers to add them.
>> >>    {% block content %}{% endblock %}
>> >>    {% block footer %}
>> >>    
>> >>    Thanks for visiting my site.
>> >>    {% endblock %}
>> >> 
>> >>
>> >> On Thu, Aug 19, 2010 at 1:11 PM, Javier Guerra Giraldez
>> >>  wrote:
>> >> > On Thu, Aug 19, 2010 at 12:03 PM, Bradley Hintze
>> >> >  wrote:
>> >> >> So do I create 'my_data_dictionary'? and whats in there?
>> >> >
>> >> > are you using render_to_response()?  can't comment on your code if
>> >> > you
>> >> > don't show it
>> >> >
>> >> > --
>> >> > Javier
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "Django users" group.
>> >> > To post to this group, send email to django-us...@googlegroups.com.
>> >> > To unsubscribe from this group, send email to
>> >> > django-users+unsubscr...@googlegroups.com.
>> >> > For more options, visit this group at
>> >> > http://groups.google.com/group/django-users?hl=en.
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Bradley J. Hintze
>> >> Graduate Student
>> >> Duke University
>> >> School of Medicine
>> >> 801-712-8799
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-us...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> >
>> >
>> > --
>> > Greg Pelly
>> > CEO / CTO, Munchly Inc.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>>
>>
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Greg Pelly
> CEO / CTO, Munchly Inc.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Using databrowse with a different ORM?

2010-08-20 Thread bruno desthuilliers
On 19 août, 11:29, Brianna Laugher  wrote:
> Hi,
>
> I have a read-only Oracle database that I'd like to use Django's
> databrowse to, well, browse. However Django's primary key requirement,
> along with my database being read-only, means I can't use Django's
> default models and DB handling.
>
> If I use something else like SQLAlchemy, so that I can specify
> composite primary keys, will I be able to use databrowse?

The answer is "very obviously, NO".

> I had a bit
> of a look at the databrowse source, but I'm new to Django and and
> nothing immediately jumped out at me as a gotcha.

Except the fact that Databrowse is totally dependent on Django's ORM ?
Have a look at datastructure.py for example:
http://code.djangoproject.com/browser/django/trunk/django/contrib/databrowse/datastructures.py


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



Re: adding a summary field to a model

2010-08-20 Thread bruno desthuilliers


On 20 août, 00:32, widoyo  wrote:
> Try to add function 'quota_ore' below.
>
> On Aug 19, 3:03 am, djnubbio  wrote:> Sorry for 
> wasting your preciuose time. I'm very newby in django.
>
> > I have de following
>
> > class Commessa(models.Model):
> >     commessa = models.CharField(max_length=20)
> >      quota_oraria=models.DecimalField(max_digits=5, decimal_places=2)
> >   ...
>
>    def quota_ore(self):
>       self.quota_oraria * sum([d.ore for d in self.diario_set.all()])

Actually,

def quota_ore(self):
   return self.quota_oraria * sum([d.ore for d in
self.diario_set.all()])

would work better... At least it would return something instead of
None !-)

Then you could avoid useless model instances creation, as well as the
temporary list:

def quota_ore(self):
   return self.quota_oraria *
sum(self.diario_set.values_list('ore', flat=True))


But still : sum() is a standard SQL aggregation function, so it
probably (yes, that's an understatement) would be faster and cheaper
to just let the SQL engine do the hard work:


from django.db.models import Sum

 def quota_ora(self):
   return self.quota_oraria * self.diario_set.aggregate(Sum('ore'))
['sum__ore']


NB : not tested but according to the FineManual and my it should
JustWork(tm).
HTH

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



Re: adding a summary field to a model

2010-08-20 Thread djnubbio
yes you are right. Howto?

On 19 Ago, 17:47, Mathieu Leduc-Hamel  wrote:
> But by the way you field seem to be a sum of some others, maybe it should
> not be a new field but just a new method returing the resulting calculation
> depending of the attributes of your instance. No ?
>
> On Thu, Aug 19, 2010 at 4:56 PM, bruno desthuilliers <
>
> bruno.desthuilli...@gmail.com> wrote:
> > On 19 août, 16:25, Nick  wrote:
> > > You need to look at overriding the model's save method in order to add
> > > data from one field to another dynamically.
>
> > Useless denormalization (until proved otherwise of course...).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: adding a summary field to a model

2010-08-20 Thread djnubbio
in fact I DO NOT want denormilize

On 19 Ago, 16:56, bruno desthuilliers 
wrote:
> On 19 août, 16:25, Nick  wrote:
>
> > You need to look at overriding the model's save method in order to add
> > data from one field to another dynamically.
>
> Useless denormalization (until proved otherwise of course...).

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



Re: adding a summary field to a model

2010-08-20 Thread djnubbio
Hu, denormalizing...it isn't best solution

On 19 Ago, 16:25, Nick  wrote:
> You need to look at overriding the model's save method in order to add
> data from one field to another dynamically.
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-mod...
>
> On Aug 19, 2:03 am, djnubbio  wrote:
>
> > Sorry for wasting your preciuose time. I'm very newby in django.
>
> > I have de following
>
> > class Commessa(models.Model):
> >     commessa = models.CharField(max_length=20)
> >      quota_oraria=models.DecimalField(max_digits=5, decimal_places=2)
> >   ...
>
> > class Diario(models.Model):
> >     data= models.DateField('data inizio')
> >     commessa = models.ForeignKey(Commessa)
> >     ore=models.IntegerField()
> > ...
>
> > I want to add a column to Commessa containg the result of:
>
> > quota_oraria * sum(ore)
>
> > for each item in commessa.
>
> > any suggestion will be greatly appreciated; tank vwry much 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: adding a summary field to a model

2010-08-20 Thread djnubbio
tank very much, widoyo.  It was what i was looking for...and It works.

On 20 Ago, 00:32, widoyo  wrote:
> Try to add function 'quota_ore' below.
>
> On Aug 19, 3:03 am, djnubbio  wrote:> Sorry for 
> wasting your preciuose time. I'm very newby in django.
>
> > I have de following
>
> > class Commessa(models.Model):
> >     commessa = models.CharField(max_length=20)
> >      quota_oraria=models.DecimalField(max_digits=5, decimal_places=2)
> >   ...
>
>    def quota_ore(self):
>       self.quota_oraria * sum([d.ore for d in self.diario_set.all()])
>
> > class Diario(models.Model):
> >     data= models.DateField('data inizio')
> >     commessa = models.ForeignKey(Commessa)
> >     ore=models.IntegerField()
> > ...
>
> > I want to add a column to Commessa containg the result of:
>
> > quota_oraria * sum(ore)
>
> Widoyo

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