Re: Need help intercepting SQL

2011-07-11 Thread Kirill Spitsin
On Sun, Jul 10, 2011 at 02:41:59PM -0700, Eric B wrote:
> Our web site uses Django 1.2.  We're adding a layer to our MySQL
> database called dbShards for fragmentation (sharding).  I need to
> prepend instructive SQL comments (/* ... */) to UPDATE statements in
> certain situations.  What's the best way to intercept the raw SQL sent
> to the database?

You can override django.db.models.sql.compiler.SQLUpdateCompiler.as_sql()
method [1], and then make a custom database backend, which would point to
your modified compiler ([2], [3]).  Or you could monkey-patch Django's compiler.
Feels somewhat hackish, but should work :).

.. [1] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/models/sql/compiler.py#L812
.. [2] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/backends/__init__.py#L106
.. [3] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/backends/__init__.py#L280

-- 
Kirill Spitsin

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



Re: my frist django project Error

2011-07-11 Thread bruno desthuilliers
On Jul 9, 10:21 pm, morning yao  wrote:
> so ,here is the Error Traceback,i need your help,thanks!
(...)
> File "C:\Python27\Lib\site-packages\django\dinette\..\dinette
> \models.py" in 
>   18.
> logging.config.fileConfig(settings.LOG_FILE_NAME,defaults=dict(log_path=settings.LOG_FILE_PATH))
> File "C:\Python27\lib\site-packages\django\utils\functional.py" in
> __getattr__
>   277.         return getattr(self._wrapped, name)
>
> Exception Type: AttributeError at /
> Exception Value: 'Settings' object has no attribute 'LOG_FILE_NAME'

As the traceback kindly explain, the dinette.models module is trying
to access non-existing attributes of the settings module. You'd need
to define LOG_FILE_NAME and LOG_FILE_PATH in your settings or use
getattr(setting, "ATTRIBUTE_NAME", default_value) instead (cf Python's
doc for getattr).

As a side note, configuring the logging module in a models module is
definitly *not* a good idea. If you're using django 1.3+, there are
better ways, please refer to the relevant doc.

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



Re: 'WSGIRequest' object has no attribute 'update'

2011-07-11 Thread Phang Mulianto
Hi Shawn,

Here are the view called :

# Create your views here.
from django.shortcuts import render_to_response
from django.template import RequestContext
from ecomstore.cart import cart

def show_cart(request, template_name="cart/cart.html"):
if request.method == 'POST':
postdata = request.POST.copy()
if postdata['submit'] == 'Remove':
cart.remove_from_cart(request)
if postdata['submit'] == 'Update':
cart.update_cart(request)

cart_item_count = cart.cart_item_count(request)
page_title = "Shopping Cart"
cart_subtotal = cart.cart_subtotal(request)
return render_to_response(template_name, locals(),
context_instance=(request))

Thanks for your help..

On Sun, Jul 10, 2011 at 11:57 PM, Shawn Milochik  wrote:

> May we see the rest of your view? If not, you'll have to figure it out by
> examining exactly what your 'request' variable contains. The error is
> clearly from calling update() on it, and it not being allowed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Re: Need help intercepting SQL

2011-07-11 Thread bruno desthuilliers
On Jul 11, 4:22 am, Venkatraman S  wrote:
> I am taking a very wild guess, as i have not pored over the docs,
> but does a middleware which proxies the sqls help you? I think
> i saw one such in djangosnippets.

Middlewares are only used in the request/response cycle. Not the right
place for db-level stuff.

@OP: I think your better bet would be to implement your own db
backend, deriving from django's mysql backend.

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



Saint Petersburg Django meetup!

2011-07-11 Thread Valentin Golev
Hello, my fellow Django users!

I'd like to invite you a meetup of Django users in Saint Petersburg,
Russia, this Saturday. We think that the growing more than ever
community of developers who use Django in Petersburg is overdue to
meet, drink some tea and talk about the future.

If you live in Saint Petersburg or going to be visiting SPb on
Saturday, please come and meet us. The meeting will take place at
"HomeWork", Ulitsa Rubinshteyna, 15/17, ap. 259. We're going to start
at 15:30, Saturday, 16th of July 2011.

For more information, please take a look at http://vkontakte.ru/event28601307.
If you don't use this website, you can also read more at
http://pep8.ru/event/2/post/2 . Please take a look at one of these
webpages to avoid problems with getting into the venue.

Our page at Lanyrd: http://lanyrd.com/2011/djangotea/

Please help us spread the word: tell your friends and colleagues about
our meeting.

If you have any problems, you can ask in this thread or contact me
directly: v...@whitescape.com.

Thank you. Looking forward to see you at the meeting!

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



Re: Getting a subclass from an abstract Model

2011-07-11 Thread gontran
Hi Micky,

sorry for my late answer but I havn't been working this week-end.
I just tried your trick but it doesn't work. I don't think it's a
probleme of manager, because if I want to query a subclass directly by
its name, it works:
ClassA.objects.all() works normally.

On 8 juil, 19:48, Micky Hulse  wrote:
> Try adding the below to your base class:
>
>     objects = models.Manager() # Admin uses this manager.
>
> Sent from my iPhone

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



Re: Getting a subclass from an abstract Model

2011-07-11 Thread gontran
Nevermind,

I will do differently...

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



Re: Model translation

2011-07-11 Thread Uros Trebec
Did anyone try "django-nani"?

https://github.com/ojii/django-nani

I'm giving it a go with my multilingual project and it kind of works.
The translating part works nicely, the biggest issue I have is the
limited AdminModel functionality (
http://django-nani.readthedocs.org/en/latest/public/admin.html#modeladmin-apis-not-available-on-translatableadmin
).

But other than that, looks promissing.

-- UT

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



Re: Getting a subclass from an abstract Model

2011-07-11 Thread Michal Petrucha
On Fri, Jul 08, 2011 at 09:02:06AM -0700, gontran wrote:
> Hello everyone,
> 
> 
> my models are defined like this:
> 
> class MyBaseModel(models.Model):
> .
> class Meta:
> abstract = True
> 
> class ClassA(MyBaseModel):
> ..
> 
> class ClassB(MyBaseModel):
> ..
> 
> Then I'm trying to get a subclass of MyBaseModel by doing this:
> 
> for s in MyBaseModel.__subclasses__():
> if s.__name__ ==  "ClassA":
> MyClass = s
> elif s.__name__ ==  "ClassB":
> MyClass = s
> q = MyClass.objects.all()===> Raise an AttributeError: type object
> 'ClassA' has no attribute '_default_manager'
> 
> I don't understand why it raises this error, what am I missing?

I'd say (though I may be absolutely wrong) that this is caused by the
fact that model classes are processed by the ModelBase metaclass. My
guess is (and it is really just a guess, since I can't find anything
more about __subclasses__ than that it exists [1]) that __subclasses__
returns a reference to the original class as defined in the Python
code, before it is processed by the metaclass.

Looking at one example abstract model class I have in my own project,
this appears to be the case. In the class returned by __subclasses__()
of the abstract class I see only things defined in models.Model and in
the abstract class, but none of the fancy stuff (like model fields or
managers, i. e. the stuff that is processed by the metaclass) I
defined in the concrete model.

Michal

[1] http://docs.python.org/library/stdtypes.html#class.__subclasses__


signature.asc
Description: Digital signature


Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread i...@webbricks.co.uk
what about mentioning this as well?

http://learnpythonthehardway.org/

4 lessons through it myself, so cant rate it just yet, but some of the
more experienced people in the group might know it/rate it.

Matt

On Jul 11, 4:30 am, Kenneth Gonsalves  wrote:
> On Sun, 2011-07-10 at 14:39 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
>
>
>
>
>
>
>
>
>
> > We don't seem to have a policy of dealing with mailing list posts in
> > which
> > the user clearly has no Python experience.
>
> > Therefore, I'd like to hear some thoughts on making an amendment to
> > UsingTheMailingList,
> > which states:
>
> > """
> > Do you have *any* experience at all using Python, or understand the
> > basic
> > concepts of how Python work?
>
> > If not, please refer to the following before attempting to use Django:
> >http://wiki.python.org/moin/BeginnersGuide/Programmers
>
> > """
>
> > This would be just the same principle if someone wanted to learn, say
> > "CodeIgniter", but without having to learn PHP. It's just not gonna
> > fly,
> > right?
>
> please go ahead and add it.
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



Re: Getting a subclass from an abstract Model

2011-07-11 Thread gontran
You may be right but like I said, I will do differently:
for s in MyBaseModel.__subclasses__():
if s.__name__ ==  "ClassA":
MyClass = ClassA
elif s.__name__ ==  "ClassB":
MyClass = ClassB

it was so simple!!!

Thank you anyway.

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



Re: ANN: django-iadmin

2011-07-11 Thread sax
should be solved in github.

sax


2011/7/11 Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk>

> Oh and, the fix I pasted here is *somewhat* hacky, and is really just meant
> to get you off the ground. The maintainer will need to patch this at a later
> date though.
>
> Cal
>
>
> On Mon, Jul 11, 2011 at 1:36 AM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Hmm, grp is only valid on unix platforms according to here:
>>
>> http://docs.python.org/library/grp.html
>>
>> https://github.com/saxix/django-iadmin/blob/master/iadmin/plugins/fm/fs.py
>>
>> *line 4-6:*
>>
>> from grp import getgrgid
>>
>>
>> from pwd import getpwuid
>>
>>
>>
>> *Replace with this:*
>> *
>> *
>> import os
>> if not os.name == 'nt':
>> from grp import getgrgid
>> from pwd import getpwuid
>>
>>
>> *line 40-41:*
>>
>> self.user = getpwuid(itemstat.st_uid)[0]
>>
>>
>> self.group = getgrgid(itemstat.st_gid)[0]
>>
>>
>>
>> *Replace with this:*
>>
>> if not os.name == 'nt':
>> self.user = getpwuid(itemstat.st_uid)[0]
>> self.group = getgrgid(itemstat.st_gid)[0]
>> else:
>> self.user = 0
>> self.group = 0
>>
>> This may or may not work lol.
>>
>> Cal
>>
>> On Mon, Jul 11, 2011 at 1:31 AM, leo  wrote:
>>
>>>  hi, sax
>>> After downloading the newest code and i try to implement the iadmin
>>> the setup works well this time but when I try to access the
>>> localhost/admin
>>> got the follow error ,
>>>
>>> My platform Win2008R2, python 2.6.6
>>>
>>> I checked the code found something,
>>> I write my code in Win, and in Win python can not import grp.
>>> but when i try import in FreeBSD it works.My win's python install
>>> by default.
>>> So I think your iadmin is not suitable for Windows now.
>>>
>>>
>>>  ImportError at /admin
>>>
>>>
>>> No module named grp
>>>
>>>   Request Method: GET  Request URL: http://localhost:/admin  Django
>>> Version: 1.3  Exception Type: ImportError  Exception Value:
>>>
>>> No module named grp
>>>
>>>   Exception Location: D:\Python26\lib\site-packages\iadmin\plugins\fm\fs.py
>>> in , line 4  Python Executable: D:\Python26\python.exe  Python
>>> Version: 2.6.6  Python Path:
>>>
>>> ['D:\\Documents\\Workspace\\server',
>>>  'C:\\Windows\\system32\\python26.zip',
>>>  'D:\\Python26\\DLLs',
>>>  'D:\\Python26\\lib',
>>>  'D:\\Python26\\lib\\plat-win',
>>>  'D:\\Python26\\lib\\lib-tk',
>>>  'D:\\Python26',
>>>  'D:\\Python26\\lib\\site-packages']
>>>
>>>   Server time: Mon, 11 Jul 2011 08:22:54 +0800
>>>
>>>
>>>
>>>
>>>
>>> On 2011/7/10 12:30, leo wrote:
>>>
>>> hi, sax
>>> I downloaded the package and want to install is using normal way
>>> then I got error like this:
>>>
>>> D:\saxix-django-iadmin-ec7ad2a>setup.py install
>>> Traceback (most recent call last):
>>>   File "D:\saxix-django-iadmin-ec7ad2a\setup.py", line 44, in 
>>> version = ".".join(iadmin.__version__),
>>> TypeError: sequence item 0: expected string, int found
>>>
>>> I got confused because the package install procedure is different
>>> with online's manual...
>>>
>>>
>>>
>>> On 2011/7/5 3:26, sax wrote:
>>>
>>> yep, but more test needed
>>>
>>> sax
>>>
>>>
>>>
>>> 2011/7/4 Fred Chevitarese 
>>>
 Hmmm I like it !

  All those features are already working?


  ^^


  "
 *O relógio da vida recebe corda apenas uma vez.*
 *Ninguém tem o poder de decidir quando os ponteiros pararão, se mais
 cedo ou se mais tarde.*
 *O presente é o único tempo que você possui.*
 *Viva, ame e trabalhe com vontade.*
  *Não ponha nenhuma esperança no tempo, pois o relógio pode parar a
 qualquer momento.*
 "

  Fred Chevitarese - GNU/Linux
 http://chevitarese.wordpress.com





  2011/7/4 creecode 

> Sounds interesting!  Thanks!
>
>
> On Monday, July 4, 2011 11:06:44 AM UTC-7, sax wrote:
>>
>> Django iAdmin
>>
>> iAdmin is a replacement of standard django admin application.
>> Features
>>
>>- multiple columns portlets-like home page
>>- tabbed view of inlines
>>- mass updates functionality
>>- export to csv with options and formatting
>>- advanced import from csv with foreign key handling
>>- link to foreignkey edit page from changelist
>>(list_display_rel_links)
>>- filter by cell values (cell_filters)
>>- ajax autocomplete widgets for ForeignKey
>>- auto register missed modules.
>>- auto add fields not present in fieldset (add_undefined_fields)
>>- utilities ( tabular_factory)
>>- info page for packages and application version
>>- integrated file manager with upload/zip functionality
>>- WYSIWYG editor wymeditor
>>- shortcuts to configure django.contrib.* applications
>>
>>   --
> You received this message because you are subscribed to the Google
> Groups "Djan

Re: 'WSGIRequest' object has no attribute 'update'

2011-07-11 Thread Malcolm Box
Hi,.

On 11 July 2011 08:29, Phang Mulianto  wrote:

>
>
> return render_to_response(template_name, locals(),
> context_instance=(request))
>

The bug is in this line. render_to_response() takes a dictionary as the
context_instance, but this code just passes the request instance.

You probably meant either:

return render_to_response(template_name, locals(),
context_instance=(request, ))  # Note comma

or

return render_to_response(template_name, locals(),
context_instance={'request':request}))

HTH,

Malcolm

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



Re: need help with calling following complex query

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Thats pretty cool, I didnt know you could do create function. Will check
this out later :)
On 11 Jul 2011 06:06, "Venkatraman S"  wrote:
> On Mon, Jul 11, 2011 at 10:02 AM, sanket  wrote:
>
>> I think I would go ahead with executing the raw SQL in this case.
>> The solution by @Venatraman looks interesting too. I would give it a
>> try.
>>
>
> Raw-sql and the snippet provided by me would end up generating the same
sql.
>
> One advantage of my snippet is, if your db does not support sin/cos
> functions(like sqlite3),
> then you can go ahead defining funcs which computes the same. Something
> like..
> from django.db import connection, transaction
> cursor = connection.cursor()
> import math
> connection.connection.create_function('acos', 1,
> math.acos)
> connection.connection.create_function('cos', 1,
> math.cos)
> connection.connection.create_function('sin', 1,
> math.sin)
>
> -V
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Scaling to 30k requests (malcolm box blog)

2011-07-11 Thread Malcolm Box
Thanks for the recommendations Cal. I hope this stuff is of use to some
people - let me know if anyone wants to know more.

On 10 July 2011 21:06, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Came across the following blog entries today, for those interested in this
> sort of thing:
>
>
> http://attentionshard.wordpress.com/2011/04/26/scaling-django-to-3-requests-per-second/
>
>
> http://attentionshard.wordpress.com/2011/04/03/scaling-to-30k-two-level-caches/
> Interesting approach. Although you'd have to be careful what context it was
> used in (i.e. if your code is written under the assumption that the caching
> server is atomic).
>

Actually atomicity is preserved for updates, as all updates go to the L2
cache servers (so are as atomic as memcache over multiple servers is). The
main gotcha is that you have to be happy that different servers can have
values that are up to N seconds out of date - but generally that's not too
bad, as it's pretty much the same situation as using a reverse proxy cache.


>
> http://attentionshard.wordpress.com/2011/04/26/scaling-to-30k-tsung/
> Never heard of tsung before, looks pretty nice. Will try it out for sure.
>
>
Can't recommend Tsung highly enough. It Just Works for testing large numbers
of concurrent connections, which is more than I can say for other tools I've
tried (apachebench, JMeter, swarm of bees). There's several companies around
that offer to do high load testing but last time I checked their rates were
sky-high.


> The stack they have used is quite interesting. Although they are using
> Apache w/ mod_wsgi (which tends to be a lot slower than using nginx with
> uwsgi), they still seem to have got some decent performance out of it.


Indeed, it's on the to-do list to try comparing the performance of
Apache/mod_wsgi with nginx/uwsgi, but my gut feel is that the webserver +
WSGI container makes only a marginal difference to the overall site
performance. Of course, I Could Be Wrong.

>
>
> http://attentionshard.wordpress.com/2011/06/21/behind-the-scenes-using-cassandra-acunu-to-power-britains-got-talent/
> Explains a bit of their usage of using Cassandra. Would be interesting to
> see some benchmarks though.
>

What benchmarks would you like to see? We sustained 10K writes/second into a
2 node m1.large cluster if that helps.

Malcolm

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



Re: CSRF problem with /i18n/setlang/

2011-07-11 Thread cjwalter
Yes, the internationalization part seems to be configured ok and
appears working. It is really the CSRF failure that bogging me.

Apart from my current project I just created a fresh one (using Django
1.3) just to confirm the issue is not caused by possible side-effects
from within my original project (which I am migrating from
djangoappengine where  i18l works fine...)

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



Re: my frist django project Error

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On 11 Jul 2011 04:39, "Kenneth Gonsalves"  wrote:
>
> On Sun, 2011-07-10 at 20:13 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
> > > Telling someone they need to learn more python isn't helpful - tell
> > them
> > > that theres a setting missing and how the traceback makes that
> > clear.
> > >
> >
> > That's a fair point tbh.
> >
> > I'll make sure to use a more friendly approach for future threads like
> > this.
> > :)
>
> looks like we need to add a section on how to answer questions also.

+1 on this.

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

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On 11 Jul 2011 10:07, "i...@webbricks.co.uk"  wrote:
>
> what about mentioning this as well?
>
> http://learnpythonthehardway.org/

Havent come across this before.. perhaps you could send a review to the list
of your experiences with it?

If anyone else in the list has used this ,could you post some thoughts about
it please??

> 4 lessons through it myself, so cant rate it just yet, but some of the
> more experienced people in the group might know it/rate it.
>
> Matt
>
> On Jul 11, 4:30 am, Kenneth Gonsalves  wrote:
> > On Sun, 2011-07-10 at 14:39 +0100, Cal Leeming [Simplicity Media Ltd]
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > We don't seem to have a policy of dealing with mailing list posts in
> > > which
> > > the user clearly has no Python experience.
> >
> > > Therefore, I'd like to hear some thoughts on making an amendment to
> > > UsingTheMailingList<
https://code.djangoproject.com/wiki/UsingTheMailingList>,
> > > which states:
> >
> > > """
> > > Do you have *any* experience at all using Python, or understand the
> > > basic
> > > concepts of how Python work?
> >
> > > If not, please refer to the following before attempting to use Django:
> > >http://wiki.python.org/moin/BeginnersGuide/Programmers
> >
> > > """
> >
> > > This would be just the same principle if someone wanted to learn, say
> > > "CodeIgniter", but without having to learn PHP. It's just not gonna
> > > fly,
> > > right?
> >
> > please go ahead and add it.
> > --
> > regards
> > KGhttp://lawgon.livejournal.com
> > Coimbatore LUG roxhttp://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: RegistrationForm subclass not showing up

2011-07-11 Thread katstevens
I think that's it! I'm using v0.7 and will upgrade now - thanks for
the heads up.

On Jul 8, 6:52 pm, CareerDhaba tech  wrote:
> I believe you are using an older version of django_registration, since there
> is no reference to the backend in your code. The backend is an addition in
> the latest (0.8) version of django_registration.
>
> Did you download the code from 
> here?http://readthedocs.org/docs/django-registration/en/latest/index.html
>

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 10:44 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> > http://learnpythonthehardway.org/
> 
> Havent come across this before.. perhaps you could send a review to
> the list
> of your experiences with it?

the person who wrote it was quite often on #django
> 
> If anyone else in the list has used this ,could you post some thoughts
> about
> it please?? 

a bit painful, but does a good job if one has the patience not to cheat.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: my frist django project Error

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 10:40 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> >
> > looks like we need to add a section on how to answer questions also.
> 
> +1 on this. 

started:
https://code.djangoproject.com/wiki/UsingTheMailingList#Howtoanswerquestionsonthelist
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Scaling to 30k requests (malcolm box blog)

2011-07-11 Thread Roberto De Ioris

>
>> The stack they have used is quite interesting. Although they are using
>> Apache w/ mod_wsgi (which tends to be a lot slower than using nginx with
>> uwsgi), they still seem to have got some decent performance out of it.
>
>
> Indeed, it's on the to-do list to try comparing the performance of
> Apache/mod_wsgi with nginx/uwsgi, but my gut feel is that the webserver +
> WSGI container makes only a marginal difference to the overall site
> performance. Of course, I Could Be Wrong.
>
>>
>>


After 2 years of continuous development on uWSGI, i can confirm you that
performance impact is pratically non-existent (most of the time, when you
see extreme favorable benchmark for uWSGI/gunicorn/fapws/flup/.../ against
mod_wsgi they are caused by the lack of apache skills of the guy doing the
benchmark)

Obviously you can tune uWSGI a little bit more that the others, but what
is the purpose of gaining 3% on a Hello World ?

As a proof, gunicorn and fapws, even if being coded in pure python are
perfectly comparable in performance with c-based solutions.

"Benchmarkers" should focus on other things (even ease-of-use if they want
uWSGI to poorly lose, or on all the other things if they want uWSGI to
easily win :P)

So, stop wasting time measuring already discovered things :)

-- 
Roberto De Ioris
http://unbit.it

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



Re: my frist django project Error

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Look good (i've added 1 line).

Nice work on adding the TOC, didn't know about that.

Cal

On Mon, Jul 11, 2011 at 11:19 AM, Kenneth Gonsalves
wrote:

> On Mon, 2011-07-11 at 10:40 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
> > >
> > > looks like we need to add a section on how to answer questions also.
> >
> > +1 on this.
>
> started:
>
> https://code.djangoproject.com/wiki/UsingTheMailingList#Howtoanswerquestionsonthelist
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: http auth using django auth_user table

2011-07-11 Thread Tom Evans
On Sun, Jul 10, 2011 at 2:30 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> The only connection this question has with Django, is the encryption method
> that Django uses, and therefore is inappropriate for this forum.
> Please refer to http://code.djangoproject.com/wiki/UsingTheMailingList
> On a site note, it took me less than 10 seconds on Google (with a very
> simple search term - first result) to find the answer you needed, which
> shows either lack of intuition or total laziness on your part.
> Cal
>

Wait what? The guy wanted to use Apache to prompt for basic auth,
using django.contrib.auth as a datastore for usernames and passwords -
why is it inappropriate to ask about extending Django's auth on a
django user mailing list? I'm also surprised that you found the answer
the OP needed in 10 seconds (and failed to link the OP to it), given
that there is no direct solution AFAICT.

Far too many people are spending too much time on this mailing list
discussing how to respond to users and what is proper to discuss on
here, and finding the perfect stock answer to tell people to eff off,
rather than actually trying to help them.

OP: This is actually tricky to do. Apache's mod_authn_dbd expects the
passwords to be in certain explicit formats[1], which do not
correspond to how Django's django.contrib.auth package stores the
passwords. As this blog post[2] explains, the issue is that apache
does not take into account the salt used to secure the password
hashes. You could try contacting the author of that post, as he has
written his own way around it.

Cheers

Tom

[1] http://httpd.apache.org/docs/trunk/misc/password_encryptions.html
[2] http://www.david-reid.com/cynic/2009/02/24/django-apache-auth/

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Added

On Sun, Jul 10, 2011 at 4:44 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> How about this..
>
> ---
> Asking question about Python related subjects is fine as long as;
>
> * You follow the same guidelines as the rest of this document
> * The question itself is somehow vaguely related to your Django project
> * You understand that learning Django will involve learning Python as well.
>
> For those who would like to read some tutorials on the basics of Python,
> you could try:
> http://wiki.python.org/moin/BeginnersGuide/Programmers
>
> ---
>
>
> On Sun, Jul 10, 2011 at 4:40 PM, Venkatraman S  wrote:
>
>> Actually, i thought about this a little more...as Brian has suggested, we
>> shouldnt shun away 'prospective' pythonistas.
>> Probably, we can keep the tone a little friendly...
>>
>> --
>>
>> Do you have *any* experience at all using Python, or understand the basic
>> concepts of how Python work?
>> If not, probably you can spend some time learning the basics; this would
>> help you a lot when you get on speed with Django.
>>
>>
>> If not, please refer to the following before attempting to use Django:
>>  http://wiki.python.org/moin/BeginnersGuide/Programmers
>>
>> If you are clueless, then you all the more welcome to the community :)
>>
>> 
>>
>> -V
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Re: 'WSGIRequest' object has no attribute 'update'

2011-07-11 Thread Phang Mulianto
>
>
> The bug is in this line. render_to_response() takes a dictionary as the
> context_instance, but this code just passes the request instance.
>
> You probably meant either:
>
> return render_to_response(template_name, locals(),
> context_instance=(request, ))  # Note comma
>
> or
>
> return render_to_response(template_name, locals(),
> context_instance={'request':request}))
>
> HTH,
>
> Malcolm
>
>
> Hi Malcolm,

already try your reccomendation, but still got error.

and i check with other view in the apps, i found out you are right, the bug
is in the render_to_response.

i fix it with this one :
  return render_to_response(template_name,
locals(),context_instance=RequestContext(request))

i miss the RequestContext(request))

This one think which pass all the context processed variable to the
template.

Thanks, and i learn now how to read error message and track it down now..

It solved now..

continue to learning...

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Actually, that does look quite nice. Although I can't comment on how
accurate the information is without using it myself.

KG, is the site fairly accurate??

Cal

On Mon, Jul 11, 2011 at 10:58 AM, Kenneth Gonsalves
wrote:

> On Mon, 2011-07-11 at 10:44 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
> > > http://learnpythonthehardway.org/
> >
> > Havent come across this before.. perhaps you could send a review to
> > the list
> > of your experiences with it?
>
> the person who wrote it was quite often on #django
> >
> > If anyone else in the list has used this ,could you post some thoughts
> > about
> > it please??
>
> a bit painful, but does a good job if one has the patience not to cheat.
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: ANN: django-iadmin

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Nice,

Can a Windows user please test and confirm:

https://github.com/saxix/django-iadmin/issues/4

Thanks

Cal

On Mon, Jul 11, 2011 at 10:23 AM, sax  wrote:

> should be solved in github.
>
> sax
>
>
> 2011/7/11 Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk>
>
> Oh and, the fix I pasted here is *somewhat* hacky, and is really just meant
>> to get you off the ground. The maintainer will need to patch this at a later
>> date though.
>>
>> Cal
>>
>>
>> On Mon, Jul 11, 2011 at 1:36 AM, Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk> wrote:
>>
>>> Hmm, grp is only valid on unix platforms according to here:
>>>
>>> http://docs.python.org/library/grp.html
>>>
>>>
>>> https://github.com/saxix/django-iadmin/blob/master/iadmin/plugins/fm/fs.py
>>>
>>> *line 4-6:*
>>>
>>> from grp import getgrgid
>>>
>>>
>>>
>>> from pwd import getpwuid
>>>
>>>
>>>
>>>
>>> *Replace with this:*
>>> *
>>> *
>>> import os
>>> if not os.name == 'nt':
>>> from grp import getgrgid
>>> from pwd import getpwuid
>>>
>>>
>>> *line 40-41:*
>>>
>>> self.user = getpwuid(itemstat.st_uid)[0]
>>>
>>>
>>>
>>> self.group = getgrgid(itemstat.st_gid)[0]
>>>
>>>
>>>
>>>
>>> *Replace with this:*
>>>
>>> if not os.name == 'nt':
>>> self.user = getpwuid(itemstat.st_uid)[0]
>>> self.group = getgrgid(itemstat.st_gid)[0]
>>> else:
>>> self.user = 0
>>> self.group = 0
>>>
>>> This may or may not work lol.
>>>
>>> Cal
>>>
>>> On Mon, Jul 11, 2011 at 1:31 AM, leo  wrote:
>>>
  hi, sax
 After downloading the newest code and i try to implement the iadmin
 the setup works well this time but when I try to access the
 localhost/admin
 got the follow error ,

 My platform Win2008R2, python 2.6.6

 I checked the code found something,
 I write my code in Win, and in Win python can not import grp.
 but when i try import in FreeBSD it works.My win's python install
 by default.
 So I think your iadmin is not suitable for Windows now.


  ImportError at /admin

 No module named grp

   Request Method: GET  Request URL: http://localhost:/admin  Django
 Version: 1.3  Exception Type: ImportError  Exception Value:

 No module named grp

   Exception Location: D:\Python26\lib\site-packages\iadmin\plugins\fm\fs.py
 in , line 4  Python Executable: D:\Python26\python.exe  Python
 Version: 2.6.6  Python Path:

 ['D:\\Documents\\Workspace\\server',
  'C:\\Windows\\system32\\python26.zip',
  'D:\\Python26\\DLLs',
  'D:\\Python26\\lib',
  'D:\\Python26\\lib\\plat-win',
  'D:\\Python26\\lib\\lib-tk',
  'D:\\Python26',
  'D:\\Python26\\lib\\site-packages']

   Server time: Mon, 11 Jul 2011 08:22:54 +0800





 On 2011/7/10 12:30, leo wrote:

 hi, sax
 I downloaded the package and want to install is using normal way
 then I got error like this:

 D:\saxix-django-iadmin-ec7ad2a>setup.py install
 Traceback (most recent call last):
   File "D:\saxix-django-iadmin-ec7ad2a\setup.py", line 44, in 
 version = ".".join(iadmin.__version__),
 TypeError: sequence item 0: expected string, int found

 I got confused because the package install procedure is different
 with online's manual...



 On 2011/7/5 3:26, sax wrote:

 yep, but more test needed

 sax



 2011/7/4 Fred Chevitarese 

> Hmmm I like it !
>
>  All those features are already working?
>
>
>  ^^
>
>
>  "
> *O relógio da vida recebe corda apenas uma vez.*
> *Ninguém tem o poder de decidir quando os ponteiros pararão, se mais
> cedo ou se mais tarde.*
> *O presente é o único tempo que você possui.*
> *Viva, ame e trabalhe com vontade.*
>  *Não ponha nenhuma esperança no tempo, pois o relógio pode parar a
> qualquer momento.*
> "
>
>  Fred Chevitarese - GNU/Linux
> http://chevitarese.wordpress.com
>
>
>
>
>
>  2011/7/4 creecode 
>
>> Sounds interesting!  Thanks!
>>
>>
>> On Monday, July 4, 2011 11:06:44 AM UTC-7, sax wrote:
>>>
>>> Django iAdmin
>>>
>>> iAdmin is a replacement of standard django admin application.
>>> Features
>>>
>>>- multiple columns portlets-like home page
>>>- tabbed view of inlines
>>>- mass updates functionality
>>>- export to csv with options and formatting
>>>- advanced import from csv with foreign key handling
>>>- link to foreignkey edit page from changelist
>>>(list_display_rel_links)
>>>- filter by cell values (cell_filters)
>>>- ajax autocomplete widgets for ForeignKey
>>>- auto register missed modules.
>>>- auto add fields not present in fieldset (add_undefined_fields)
>>>- u

something about django mysql database long connection

2011-07-11 Thread oops
hi,
Now, i am doing a django project, and use models to do all operation
about data in mysql db.

and i think that it would connect to database whenever  do some
operation like 'XXX.objects.all()' , may be it would cast much of
resource on database connection. So i need a connection never being
desconnected.

Does django has this function?  And how to do for it??

thank you
rgs,
he

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



WindowsError 32

2011-07-11 Thread Domdom
Hello! When I try to delete file from django on windows sometimes I
meet error page WindowsError 32. My model calls this method every fore
every delete:

def delete(self, using=None):
super(UserFile, self).delete(using)
self.fileobject.close()
self.fileobject.storage.delete(self.fileobject)

I tried a lot of variants, but error appears with every varient. I
found, that it is Windows/python bug. My project will be working under
the linux, but I need to develop and test it under the windows. I do
not know what to do :-(

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 12:05 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> Actually, that does look quite nice. Although I can't comment on how
> accurate the information is without using it myself.
> 
> KG, is the site fairly accurate?? 

what do you mean by 'accurate'?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



trying to use the User model

2011-07-11 Thread NISA BALAKRISHNAN
I am new to django.
I am trying to write a model that looks like dis.

class Profile(models.Model):
user = models.OneToOneField(User)
birth_date = models.DateField()
bio = models.TextField()
address = models.CharField(max_length=100)
city = models.CharField(max_length=50)
state = models.CharField(max_length=50)

def create_user_profile(sender, instance, created, **kwargs):
 if created:
Profile.objects.create(user=instance)

post_save.connect(create_user_profile, sender=User)

when i run the server this is the error message i get .
Could not import person.views. Error was: cannot import name User
pls help

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



Re: trying to use the User model

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 02:15 -0700, NISA BALAKRISHNAN wrote:
> when i run the server this is the error message i get .
> Could not import person.views. Error was: cannot import name User 

at the top of your file do:

from django.contrib.auth.models import User
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 12:12 PM, Kenneth Gonsalves
wrote:

> On Mon, 2011-07-11 at 12:05 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
> > Actually, that does look quite nice. Although I can't comment on how
> > accurate the information is without using it myself.
> >
> > KG, is the site fairly accurate??
>
> what do you mean by 'accurate'?
>

As in, did the tutorial contain any errors / false / inaccurate information?
I would check it myself, but haven't got any spare time at the moment :/ It
looks very cleanly done though, so if someone could confirm the content is
accurate, I'd defo say lets include it in the list.

Cal


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

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 12:18 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> > what do you mean by 'accurate'?
> >
> 
> As in, did the tutorial contain any errors / false / inaccurate
> information?
> I would check it myself, but haven't got any spare time at the
> moment :/ It
> looks very cleanly done though, so if someone could confirm the
> content is
> accurate, I'd defo say lets include it in the list. 

I can confirm it is accurate.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: http auth using django auth_user table

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 12:02 PM, Tom Evans wrote:

> On Sun, Jul 10, 2011 at 2:30 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > The only connection this question has with Django, is the encryption
> method
> > that Django uses, and therefore is inappropriate for this forum.
> > Please refer to http://code.djangoproject.com/wiki/UsingTheMailingList
> > On a site note, it took me less than 10 seconds on Google (with a very
> > simple search term - first result) to find the answer you needed, which
> > shows either lack of intuition or total laziness on your part.
> > Cal
> >
>
> Wait what? The guy wanted to use Apache to prompt for basic auth,
> using django.contrib.auth as a datastore for usernames and passwords -
> why is it inappropriate to ask about extending Django's auth on a
> django user mailing list? I'm also surprised that you found the answer
> the OP needed in 10 seconds (and failed to link the OP to it), given
> that there is no direct solution AFAICT.
>

http://www.google.co.uk/search?hl=en&safe=off&q=auth_mysql+salt

And I quote:

http://modauthmysql.sourceforge.net/CONFIGURE

AuthMySQLSaltField <> |  | mysql_column_name

  Contains information on the salt field to be used for crypt and aes
  encryption methods.  It can contain one of the following:
<>: password itself is the salt field (use with crypt() only)
: "string" as the salt field
mysql_column_name: the salt is take from the mysql_column_name field in the
  same row as the password

I probably should have told OP how I found the information he needed, and
what steps to take (although the steps I took are explained in the wiki).
I'll ensure to do this next time.

I would also agree that my comments about it being "inappropriate" for this
mailing list were wrong, as although the connection between the question and
Django was loose, it is still a connection nevertheless. My apologies to the
OP on this.


>
> Far too many people are spending too much time on this mailing list
> discussing how to respond to users and what is proper to discuss on
> here, and finding the perfect stock answer to tell people to eff off,
> rather than actually trying to help them.
>
> OP: This is actually tricky to do. Apache's mod_authn_dbd expects the
> passwords to be in certain explicit formats[1], which do not
> correspond to how Django's django.contrib.auth package stores the
> passwords. As this blog post[2] explains, the issue is that apache
> does not take into account the salt used to secure the password
> hashes. You could try contacting the author of that post, as he has
> written his own way around it.
>

OP said he was using mod auth_mysql, not mod_authn_dbd..? Unless I have
misunderstood something??


>
> Cheers
>
> Tom
>
> [1] http://httpd.apache.org/docs/trunk/misc/password_encryptions.html
> [2] http://www.david-reid.com/cynic/2009/02/24/django-apache-auth/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 12:19 PM, Kenneth Gonsalves
wrote:

> On Mon, 2011-07-11 at 12:18 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
> > > what do you mean by 'accurate'?
> > >
> >
> > As in, did the tutorial contain any errors / false / inaccurate
> > information?
> > I would check it myself, but haven't got any spare time at the
> > moment :/ It
> > looks very cleanly done though, so if someone could confirm the
> > content is
> > accurate, I'd defo say lets include it in the list.
>
> I can confirm it is accurate.
>

Added.

Thanks Matt for suggesting this!


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

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



Re: something about django mysql database long connection

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:

> hi,
> Now, i am doing a django project, and use models to do all operation
> about data in mysql db.
>
> and i think that it would connect to database whenever  do some
> operation like 'XXX.objects.all()' , may be it would cast much of
> resource on database connection. So i need a connection never being
> desconnected.
>

At as best guess (as the question is somewhat broken), are you asking how to
make persistent connections which are guaranteed to never time out in a
single session?

Could you clarify a little more on your question please?

Cal


>
> Does django has this function?  And how to do for it??
>
> thank you
> rgs,
> he
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: (UsingTheMailingList) Pre-requisites for newcomers on Django

2011-07-11 Thread Eyad Al Sibai
+!

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



Re: trying to use the User model

2011-07-11 Thread bruno desthuilliers
On Jul 11, 11:15 am, NISA BALAKRISHNAN 
wrote:
> I am new to django.
> I am trying to write a model that looks like dis.
>
> class Profile(models.Model):
>     user = models.OneToOneField(User)
>     birth_date = models.DateField()
>     bio = models.TextField()
>     address = models.CharField(max_length=100)
>     city = models.CharField(max_length=50)
>     state = models.CharField(max_length=50)
>
>     def create_user_profile(sender, instance, created, **kwargs):
>      if created:
>         Profile.objects.create(user=instance)
>
>     post_save.connect(create_user_profile, sender=User)

OT, but the part starting from "def create_user_profile" should live
outside the class statement.

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



Re: RegistrationForm subclass not showing up

2011-07-11 Thread katstevens
OK I must have missed something fundamental. I installed v0.8 and
having started all over again, I only made one change - adding an
extra field to the basic RegistrationForm class in registration.forms
- this isn't showing up on my template either!

Looking over my code, I've found it's not just the Registration form
class - when I try altering the default label in e.g.
PasswordResetForm (from django.contrib.auth.forms) the change doesn't
show up in my template either ( {{ form.email.label_tag }} ), it still
displays the default. Is there another mysterious source that django
is getting the form class declaration from instead, or is it just
ignoring my changes for some reason? I'm not getting any errors and
the form itself still works correctly. I haven't changed any of the
default code for PasswordResetForm (urls, views, forms) except that
one label. I can't understand this behaviour at all.

On Jul 11, 10:46 am, katstevens  wrote:
> I think that's it! I'm using v0.7 and will upgrade now - thanks for
> the heads up.
>
> On Jul 8, 6:52 pm, CareerDhaba tech  wrote:
>
>
>
>
>
>
>
> > I believe you are using an older version of django_registration, since there
> > is no reference to the backend in your code. The backend is an addition in
> > the latest (0.8) version of django_registration.
>
> > Did you download the code from 
> > here?http://readthedocs.org/docs/django-registration/en/latest/index.html

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



Re: WindowsError 32

2011-07-11 Thread bruno desthuilliers
On Jul 11, 7:53 am, Domdom  wrote:
> Hello! When I try to delete file from django on windows sometimes I
> meet error page WindowsError 32.

What is WindowsError 32 ? (believe it or else, but quite a few people
here never use this particular OS).

> My model calls this method every fore
> every delete:
>
>     def delete(self, using=None):
>         super(UserFile, self).delete(using)
>         self.fileobject.close()
>         self.fileobject.storage.delete(self.fileobject)

What is self.fileobject ?

> I tried a lot of variants, but error appears with every varient.

ProgrammingByPermutation is a well-known antipattern (http://
en.wikipedia.org/wiki/Programming_by_permutation). Better to
understand exactly WHY your code fail, so you have a chance to know
why it works once you have the problem fixed.

> I found, that it is Windows/python bug.

Do you mean that you found a link to a ticket about this exact problem
in a bugtracking system? Or that you only have this problem under
Windows ?

> My project will be working under
> the linux, but I need to develop and test it under the windows. I do
> not know what to do :-(

Please start here:
https://code.djangoproject.com/wiki/UsingTheMailingList

then come back with enough detailed informations about your problem.

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



New to Django

2011-07-11 Thread Eyad Al-Sibai
Hi!

I am new to Django, but I am not sure if I should use the built in Django
auth for registration and authorization or I should use another app/package.


Eyad

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



Re: New to Django

2011-07-11 Thread bruno desthuilliers
On Jul 11, 2:07 pm, Eyad Al-Sibai  wrote:
> Hi!
>
> I am new to Django, but I am not sure if I should use the built in Django
> auth for registration and authorization or I should use another app/package.
>

First learn to use django.auth, then if and when it doesn't fit your
needs you'll be able to extend / override it with something more
appropriate.

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



Re: CSRF problem with /i18n/setlang/

2011-07-11 Thread cjwalter
...what shall I say: problem solved. By simply using RequestContext
instead of Context. Yes, the error message said so, but I somehow
assumed that this concerns the i18l code and not my view...

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



Re: RegistrationForm subclass not showing up

2011-07-11 Thread Andre Terra
My guess is that there's another module somewhere in your PYTHONPATH from
which django is importing these forms.

Also, don't edit registration.forms, subclass the form instead.

You can also try {{ form.as_p }} to make sure the problem isn't in the
template.

You can raise an exception somewhere in your code to try to find where in
the python path the module lives. Try something like


def your_view(request):
# ...
# your current code
# ...
from registration import forms
assert False, forms.__file__


Good luck!

Cheers,
André


On Mon, Jul 11, 2011 at 8:45 AM, katstevens  wrote:

> OK I must have missed something fundamental. I installed v0.8 and
> having started all over again, I only made one change - adding an
> extra field to the basic RegistrationForm class in registration.forms
> - this isn't showing up on my template either!
>
> Looking over my code, I've found it's not just the Registration form
> class - when I try altering the default label in e.g.
> PasswordResetForm (from django.contrib.auth.forms) the change doesn't
> show up in my template either ( {{ form.email.label_tag }} ), it still
> displays the default. Is there another mysterious source that django
> is getting the form class declaration from instead, or is it just
> ignoring my changes for some reason? I'm not getting any errors and
> the form itself still works correctly. I haven't changed any of the
> default code for PasswordResetForm (urls, views, forms) except that
> one label. I can't understand this behaviour at all.
>
> On Jul 11, 10:46 am, katstevens  wrote:
> > I think that's it! I'm using v0.7 and will upgrade now - thanks for
> > the heads up.
> >
> > On Jul 8, 6:52 pm, CareerDhaba tech  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I believe you are using an older version of django_registration, since
> there
> > > is no reference to the backend in your code. The backend is an addition
> in
> > > the latest (0.8) version of django_registration.
> >
> > > Did you download the code from here?
> http://readthedocs.org/docs/django-registration/en/latest/index.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: FormMixin missing method

2011-07-11 Thread Andre Terra
Hey, Lior

Would you mind giving us an example of what you mean by setting up the
instance, and why that part of the code should live in the view? It doesn't
have to be production-quality code, just an example of the concept you have
in mind.

Cheers,
André

On Sat, Jul 9, 2011 at 5:18 PM, Lior Sion  wrote:

> Hi,
>
> Wanted to run this by you before I raise the suggestion in django-
> development: the core generic class FormMixin has some methods that
> allow to set a form: get_initial, get_form_kwargs and so on. However,
> it's missing a method to set up the instance (which has some uses) -
> should it be added?
>
> (implementation details are very simple but I can easily add them to
> the suggestion once it's done)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: WindowsError 32

2011-07-11 Thread Peter Murphy
Domdom,

The first thing to do is Google|Bing|Other Search Engine of your
choice "WindowsError 32". If you had done that, the first link:

http://msdn.microsoft.com/en-us/library/ms681382%28v=vs.85%29.aspx

Would have given you a clue:

ERROR_SHARING_VIOLATION 32 (0x20): The process cannot access the file
because it is being used by another process.

I think the issue is that your code is trying to delete a file when it
is being accessed by something else. Perhaps you forgot to close it
elsewhere?

Best regards,
Peter


On Jul 11, 9:53 pm, bruno desthuilliers
 wrote:
> On Jul 11, 7:53 am, Domdom  wrote:
>
> > Hello! When I try to delete file from django on windows sometimes I
> > meet error page WindowsError 32.
>
> What is WindowsError 32 ? (believe it or else, but quite a few people
> here never use this particular OS).
>
> > My model calls this method every fore
> > every delete:
>
> >     def delete(self, using=None):
> >         super(UserFile, self).delete(using)
> >         self.fileobject.close()
> >         self.fileobject.storage.delete(self.fileobject)
>
> What is self.fileobject ?
>
> > I tried a lot of variants, but error appears with every varient.
>
> ProgrammingByPermutation is a well-known antipattern (http://
> en.wikipedia.org/wiki/Programming_by_permutation). Better to
> understand exactly WHY your code fail, so you have a chance to know
> why it works once you have the problem fixed.
>
> > I found, that it is Windows/python bug.
>
> Do you mean that you found a link to a ticket about this exact problem
> in a bugtracking system? Or that you only have this problem under
> Windows ?
>
> > My project will be working under
> > the linux, but I need to develop and test it under the windows. I do
> > not know what to do :-(
>
> Please start here:https://code.djangoproject.com/wiki/UsingTheMailingList
>
> then come back with enough detailed informations about your problem.
>
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



speeding up iterating over query set

2011-07-11 Thread Michel30
Hi all,

I have a basic search function that uses Q objects.
After profiling it I found that the actual (mysql) database query
finishes in fractions of seconds but the iterating after this can take
up to 50 seconds per 10.000 results.

I have been trying to speed it up but I have had not much results..

My query is this one:

   found_entries = model.objects.filter((Q-objects),
obsolete=0).order_by('-version','docid')

So far so good, but then I need a dictionary to retrieve only unique
'documentid's'.

rev_dict = {}

This is the part that hurts:

for d in found_entries:
rev_dict[d.documentid] = d

And then some more sorting and filtering:

filtered_entries = rev_dict.values()
filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)

Does anyone have some better ideas to achieve this?

Thanks

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



Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 2:57 PM, Michel30  wrote:

> Hi all,
>
> I have a basic search function that uses Q objects.
> After profiling it I found that the actual (mysql) database query
> finishes in fractions of seconds but the iterating after this can take
> up to 50 seconds per 10.000 results.
>
> I have been trying to speed it up but I have had not much results..
>
> My query is this one:
>
>   found_entries = model.objects.filter((Q-objects),
> obsolete=0).order_by('-version','docid')
>
> So far so good, but then I need a dictionary to retrieve only unique
> 'documentid's'.
>

You could do:

# grab all results
_res =
model.objects.filter((Q-objects),obsolete=0).order_by('-version','docid').values()
# re-map them into (id, obj)
_res = map(lambda x: [x.docid, x], _res)
# wrap in a dict(), which uses index position 0 as the key, and index
position 1 as the value
_res = dict(_res)

Let me know if this give you the results you need.


>rev_dict = {}
>
> This is the part that hurts:
>
>for d in found_entries:
>rev_dict[d.documentid] = d
>
> And then some more sorting and filtering:
>
>filtered_entries = rev_dict.values()
>filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>
> Does anyone have some better ideas to achieve this?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 3:04 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
>
> On Mon, Jul 11, 2011 at 2:57 PM, Michel30  wrote:
>
>> Hi all,
>>
>> I have a basic search function that uses Q objects.
>> After profiling it I found that the actual (mysql) database query
>> finishes in fractions of seconds but the iterating after this can take
>> up to 50 seconds per 10.000 results.
>>
>> I have been trying to speed it up but I have had not much results..
>>
>> My query is this one:
>>
>>   found_entries = model.objects.filter((Q-objects),
>> obsolete=0).order_by('-version','docid')
>>
>> So far so good, but then I need a dictionary to retrieve only unique
>> 'documentid's'.
>>
>
> You could do:
>
> # grab all results
> _res =
> model.objects.filter((Q-objects),obsolete=0).order_by('-version','docid').values()
> # re-map them into (id, obj)
> _res = map(lambda x: [x.docid, x], _res)
> # wrap in a dict(), which uses index position 0 as the key, and index
> position 1 as the value
> _res = dict(_res)
>

Just tested the same principle, and it seems to work fine. It uses last
object found as the final choice if dups are found.

>>> _res = [ [1,2], [1,3], [2,4], [2,5] ]
>>> map(lambda x: [x[0], x[1]], _res)
[[1, 2], [1, 3], [2, 4], [2, 5]]
>>> map(lambda x: [x[0], x[1]], _res)
[[1, 2], [1, 3], [2, 4], [2, 5]]
>>> dict(map(lambda x: [x[0], x[1]], _res))
{1: 3, 2: 5}
>>>




>
> Let me know if this give you the results you need.
>
>
>>rev_dict = {}
>>
>> This is the part that hurts:
>>
>>for d in found_entries:
>>rev_dict[d.documentid] = d
>>
>> And then some more sorting and filtering:
>>
>>filtered_entries = rev_dict.values()
>>filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>>
>> Does anyone have some better ideas to achieve this?
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: speeding up iterating over query set

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
On Mon, Jul 11, 2011 at 3:06 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
>
> On Mon, Jul 11, 2011 at 3:04 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>>
>>
>> On Mon, Jul 11, 2011 at 2:57 PM, Michel30  wrote:
>>
>>> Hi all,
>>>
>>> I have a basic search function that uses Q objects.
>>> After profiling it I found that the actual (mysql) database query
>>> finishes in fractions of seconds but the iterating after this can take
>>> up to 50 seconds per 10.000 results.
>>>
>>> I have been trying to speed it up but I have had not much results..
>>>
>>> My query is this one:
>>>
>>>   found_entries = model.objects.filter((Q-objects),
>>> obsolete=0).order_by('-version','docid')
>>>
>>> So far so good, but then I need a dictionary to retrieve only unique
>>> 'documentid's'.
>>>
>>
>> You could do:
>>
>> # grab all results
>> _res =
>> model.objects.filter((Q-objects),obsolete=0).order_by('-version','docid').values()
>> # re-map them into (id, obj)
>> _res = map(lambda x: [x.docid, x], _res)
>>
> Sorry, small adjustment:

# re-map them into (id, obj), model(**x) will remap the values into new ORM
objects
_res = map(lambda x: [x.get('docid'), model(**x)], _res)


# wrap in a dict(), which uses index position 0 as the key, and index
>> position 1 as the value
>> _res = dict(_res)
>>
>
> Just tested the same principle, and it seems to work fine. It uses last
> object found as the final choice if dups are found.
>
> >>> _res = [ [1,2], [1,3], [2,4], [2,5] ]
> >>> map(lambda x: [x[0], x[1]], _res)
> [[1, 2], [1, 3], [2, 4], [2, 5]]
> >>> map(lambda x: [x[0], x[1]], _res)
> [[1, 2], [1, 3], [2, 4], [2, 5]]
> >>> dict(map(lambda x: [x[0], x[1]], _res))
> {1: 3, 2: 5}
> >>>
>
>
>
>
>>
>> Let me know if this give you the results you need.
>>
>>
>>>rev_dict = {}
>>>
>>> This is the part that hurts:
>>>
>>>for d in found_entries:
>>>rev_dict[d.documentid] = d
>>>
>>> And then some more sorting and filtering:
>>>
>>>filtered_entries = rev_dict.values()
>>>filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>>>
>>> Does anyone have some better ideas to achieve this?
>>>
>>> Thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>

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



Re: speeding up iterating over query set

2011-07-11 Thread Michel30
I didn't try this approach yet, I'll give it a go and let you know my
mileage.

Thanks

On Jul 11, 4:06 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> On Mon, Jul 11, 2011 at 3:04 PM, Cal Leeming [Simplicity Media Ltd] <
>
>
>
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
> > On Mon, Jul 11, 2011 at 2:57 PM, Michel30  wrote:
>
> >> Hi all,
>
> >> I have a basic search function that uses Q objects.
> >> After profiling it I found that the actual (mysql) database query
> >> finishes in fractions of seconds but the iterating after this can take
> >> up to 50 seconds per 10.000 results.
>
> >> I have been trying to speed it up but I have had not much results..
>
> >> My query is this one:
>
> >>       found_entries = model.objects.filter((Q-objects),
> >> obsolete=0).order_by('-version','docid')
>
> >> So far so good, but then I need a dictionary to retrieve only unique
> >> 'documentid's'.
>
> > You could do:
>
> > # grab all results
> > _res =
> > model.objects.filter((Q-objects),obsolete=0).order_by('-version','docid').values()
> > # re-map them into (id, obj)
> > _res = map(lambda x: [x.docid, x], _res)
> > # wrap in a dict(), which uses index position 0 as the key, and index
> > position 1 as the value
> > _res = dict(_res)
>
> Just tested the same principle, and it seems to work fine. It uses last
> object found as the final choice if dups are found.
>
> >>> _res = [ [1,2], [1,3], [2,4], [2,5] ]
> >>> map(lambda x: [x[0], x[1]], _res)
>
> [[1, 2], [1, 3], [2, 4], [2, 5]]>>> map(lambda x: [x[0], x[1]], _res)
>
> [[1, 2], [1, 3], [2, 4], [2, 5]]
>
> >>> dict(map(lambda x: [x[0], x[1]], _res))
> {1: 3, 2: 5}
>
> > Let me know if this give you the results you need.
>
> >>    rev_dict = {}
>
> >> This is the part that hurts:
>
> >>    for d in found_entries:
> >>        rev_dict[d.documentid] = d
>
> >> And then some more sorting and filtering:
>
> >>    filtered_entries = rev_dict.values()
> >>    filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>
> >> Does anyone have some better ideas to achieve this?
>
> >> Thanks
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: speeding up iterating over query set

2011-07-11 Thread Andre Terra
You seem to be hauling the same data from one side to the other, and I can't
see why.

Try:

MyModel.objects.values_list('id', flat=True)

You can use that to build a dictionary if you add a second field, or using
list comprehensions which I believe are faster than for loops,

dict(MyModel.objects.values_list('id', 'docid'))

but I honestly don't understand what you are trying to do. Maybe if you
share more of the model logic and explain what you are trying to achieve we
can provide you with a way to get there, instead of trying to improve the
way you decided to go about it.


Cheers,
André Terra


On Mon, Jul 11, 2011 at 10:57 AM, Michel30  wrote:

> Hi all,
>
> I have a basic search function that uses Q objects.
> After profiling it I found that the actual (mysql) database query
> finishes in fractions of seconds but the iterating after this can take
> up to 50 seconds per 10.000 results.
>
> I have been trying to speed it up but I have had not much results..
>
> My query is this one:
>
>   found_entries = model.objects.filter((Q-objects),
> obsolete=0).order_by('-version','docid')
>
> So far so good, but then I need a dictionary to retrieve only unique
> 'documentid's'.
>
>rev_dict = {}
>
> This is the part that hurts:
>
>for d in found_entries:
>rev_dict[d.documentid] = d
>
> And then some more sorting and filtering:
>
>filtered_entries = rev_dict.values()
>filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>
> Does anyone have some better ideas to achieve this?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: RegistrationForm subclass not showing up

2011-07-11 Thread katstevens
Thank you for your help Andre - I've now worked out what the problem
was. I was editing the wrong copy of the source code (it happens to
everyone at some point!) so no wonder the changes were not
happening... In the end I just created a completely new url path (i.e.
not 'accounts/register') and called registration.views with a
completely new form class in the dictionary parameter.

Here's my final code with the RegistrationForm for reference. In my
project's urls.py I added the following lines:

  import registration.backends.default.urls#
django-registration urls
  from registration.views import register#
django-registration view
  from myapp.newform import MyNewRegistrationForm # my own
customised form

  urlpatterns = patterns('',
url(r'^accounts/', include(registration.backends.default.urls)),
url(r'^accounts/registration/$', register, {'backend':
'registration.backends.default.DefaultBackend', 'form_class':
MyNewRegistrationForm  },
name='registration_register'),

I just copied the code from the original RegistrationForm class to
myapp.newform and added my customised fields, including the
TermsOfService field I originally wanted...

On Jul 11, 2:13 pm, Andre Terra  wrote:
> My guess is that there's another module somewhere in your PYTHONPATH from
> which django is importing these forms.
>
> Also, don't edit registration.forms, subclass the form instead.
>
> You can also try {{ form.as_p }} to make sure the problem isn't in the
> template.
>
> You can raise an exception somewhere in your code to try to find where in
> the python path the module lives. Try something like
>
> def your_view(request):
>     # ...
>     # your current code
>     # ...
>     from registration import forms
>     assert False, forms.__file__
>
> Good luck!
>
> Cheers,
> André
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 8:45 AM, katstevens  wrote:
> > OK I must have missed something fundamental. I installed v0.8 and
> > having started all over again, I only made one change - adding an
> > extra field to the basic RegistrationForm class in registration.forms
> > - this isn't showing up on my template either!
>
> > Looking over my code, I've found it's not just the Registration form
> > class - when I try altering the default label in e.g.
> > PasswordResetForm (from django.contrib.auth.forms) the change doesn't
> > show up in my template either ( {{ form.email.label_tag }} ), it still
> > displays the default. Is there another mysterious source that django
> > is getting the form class declaration from instead, or is it just
> > ignoring my changes for some reason? I'm not getting any errors and
> > the form itself still works correctly. I haven't changed any of the
> > default code for PasswordResetForm (urls, views, forms) except that
> > one label. I can't understand this behaviour at all.
>
> > On Jul 11, 10:46 am, katstevens  wrote:
> > > I think that's it! I'm using v0.7 and will upgrade now - thanks for
> > > the heads up.
>
> > > On Jul 8, 6:52 pm, CareerDhaba tech  wrote:
>
> > > > I believe you are using an older version of django_registration, since
> > there
> > > > is no reference to the backend in your code. The backend is an addition
> > in
> > > > the latest (0.8) version of django_registration.
>
> > > > Did you download the code from here?
> >http://readthedocs.org/docs/django-registration/en/latest/index.html
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Need help intercepting SQL

2011-07-11 Thread Eric B
> @OP: I think your better bet would be to implement your own db
> backend, deriving from django's mysql backend.

I agree and looked into this, but the backend in Django 1.2 actually
defers to the MySQLdb library.  I couldn't find any references online
that talked about or showed examples for extending a database
backend.  If you know of any, I would really appropriate it if you
could post the link(s).

Thanks,
Eric

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



Re: Need help intercepting SQL

2011-07-11 Thread Eric B
> I am taking a very wild guess, as i have not pored over the docs,
> but does a middleware which proxies the sqls help you? I think
> i saw one such in djangosnippets.

I searched djangosnippets.org for "proxy sql" and only found
http://djangosnippets.org/snippets/1913/.  That's not exactly what I'm
looking for because it's not hooked into the model's save command.  If
that's not the correct snippet, I would really appreciate it if you
could post the right one.

Thanks,
Eric

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



Re: RegistrationForm subclass not showing up

2011-07-11 Thread Andre Terra
>
> Thank you for your help Andre

You're welcome!


> I've now worked out what the problem
> was. I was editing the wrong copy of the source code (it happens to
> everyone at some point!) so no wonder the changes were not
> happening...


Happens to me more often than I'd like to admit...


> In the end I just created a completely new url path (i.e.
> not 'accounts/register') and called registration.views with a
> completely new form class in the dictionary parameter.
>

This is precisely how you're supposed to use it.


>
> Here's my final code with the RegistrationForm for reference. In my
> project's urls.py I added the following lines:
>
>  import registration.backends.default.urls#
> django-registration urls
>  from registration.views import register#
> django-registration view
>  from myapp.newform import MyNewRegistrationForm # my own
> customised form
>
>  urlpatterns = patterns('',
>url(r'^accounts/', include(registration.backends.default.urls)),
>url(r'^accounts/registration/$', register, {'backend':
> 'registration.backends.default.DefaultBackend', 'form_class':
> MyNewRegistrationForm  },
>name='registration_register'),
>



> I just copied the code from the original RegistrationForm class to
> myapp.newform and added my customised fields, including the
> TermsOfService field I originally wanted...
>

While this approach works, it is harder to maintain because any updates (ie.
fixes, new features, etc) that are added to the original RegistrationForm
will never make it to MyNewRegistrationForm. So subclassing and adding just
the TOS logic would be the best approach. It also improves readability for
you, since you'll just have to look to a couple of lines in your
MyNewRegistrationForm as opposed to the whole logic. Considering someone
else maintains django-registration, you can leave that part of the code for
them to worry and just work on your project-specific stuff.

(I'm not sure how clear that paragraph is, so feel free to ask questions!)


Cheers,
André Terra


>
> On Jul 11, 2:13 pm, Andre Terra  wrote:
> > My guess is that there's another module somewhere in your PYTHONPATH from
> > which django is importing these forms.
> >
> > Also, don't edit registration.forms, subclass the form instead.
> >
> > You can also try {{ form.as_p }} to make sure the problem isn't in the
> > template.
> >
> > You can raise an exception somewhere in your code to try to find where in
> > the python path the module lives. Try something like
> >
> > def your_view(request):
> > # ...
> > # your current code
> > # ...
> > from registration import forms
> > assert False, forms.__file__
> >
> > Good luck!
> >
> > Cheers,
> > André
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 8:45 AM, katstevens 
> wrote:
> > > OK I must have missed something fundamental. I installed v0.8 and
> > > having started all over again, I only made one change - adding an
> > > extra field to the basic RegistrationForm class in registration.forms
> > > - this isn't showing up on my template either!
> >
> > > Looking over my code, I've found it's not just the Registration form
> > > class - when I try altering the default label in e.g.
> > > PasswordResetForm (from django.contrib.auth.forms) the change doesn't
> > > show up in my template either ( {{ form.email.label_tag }} ), it still
> > > displays the default. Is there another mysterious source that django
> > > is getting the form class declaration from instead, or is it just
> > > ignoring my changes for some reason? I'm not getting any errors and
> > > the form itself still works correctly. I haven't changed any of the
> > > default code for PasswordResetForm (urls, views, forms) except that
> > > one label. I can't understand this behaviour at all.
> >
> > > On Jul 11, 10:46 am, katstevens  wrote:
> > > > I think that's it! I'm using v0.7 and will upgrade now - thanks for
> > > > the heads up.
> >
> > > > On Jul 8, 6:52 pm, CareerDhaba tech  wrote:
> >
> > > > > I believe you are using an older version of django_registration,
> since
> > > there
> > > > > is no reference to the backend in your code. The backend is an
> addition
> > > in
> > > > > the latest (0.8) version of django_registration.
> >
> > > > > Did you download the code from here?
> > >http://readthedocs.org/docs/django-registration/en/latest/index.html
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> T

Re: Need help intercepting SQL

2011-07-11 Thread DrBloodmoney
I think that you would probably have better luck coming at it from the
other end. That is, in the database itself (stored procedure or
otherwise).

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Thanks for the responses.

How do I use a foreign key, though? In other words, how do I tell my
code to look at UserProfile rather than just user?

On Jul 10, 5:08 am, Jonas Geiregat  wrote:
> Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:
>
>
>
> > This is not good design. If you want to store some extra fields for a User 
> > - i would define just another model called ProfileDetails, FK it to User 
> > and use it as such.
>
> That's also how I would do it, some example code to make it even more clear:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class UserProfile(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     url = models.URLField("Website", blank=True)
>     company = models.CharField(max_length=50, blank=True)

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Michał Sawicz
Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> How do I use a foreign key, though? In other words, how do I tell my
> code to look at UserProfile rather than just user? 

https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users

-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


Re: need help with calling following complex query

2011-07-11 Thread Jonas Geiregat
> 
> results.extra(select={
> 'distance': 
> '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(latitude)f)*cos(%(longitude)f-longitude)))'
>   % {
>  'latitude': latitude,
>  'longitude': longitude
> }
> }).order_by('distance')  
> 

This is an interesting solution to the issue. I never really looked into the 
extra method. 
So I read the docs and I'm wondering if it wouldn't be better to use the 
select_params parameter ?


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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Wherever you would reference a user instance, reference UserProfile.user
instead

If you need to find out a profile from request.user, you can use
request.user.get_profile() or the longer UserProfile.objects.get(user_id=
request.user.id)


Cheers,
André

On Mon, Jul 11, 2011 at 1:48 PM, Brent  wrote:

> Thanks for the responses.
>
> How do I use a foreign key, though? In other words, how do I tell my
> code to look at UserProfile rather than just user?
>
> On Jul 10, 5:08 am, Jonas Geiregat  wrote:
> > Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:
> >
> >
> >
> > > This is not good design. If you want to store some extra fields for a
> User - i would define just another model called ProfileDetails, FK it to
> User and use it as such.
> >
> > That's also how I would do it, some example code to make it even more
> clear:
> >
> > from django.db import models
> > from django.contrib.auth.models import User
> >
> > class UserProfile(models.Model):
> > user = models.ForeignKey(User, unique=True)
> > url = models.URLField("Website", blank=True)
> > company = models.CharField(max_length=50, blank=True)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
I am having trouble with this line of the tutorial: "You need to
register a handler for the signal django.db.models.signals.post_save
on the User model, and, in the handler, if created=True, create the
associated user profile."

It seems I need to edit the User model. I am confused, though, because
I am using the User model included in django.contrib, and I am very
hesitant to edit files that are not in my project directory.

Is this bad design to be using a mix of things I've written on my own,
and things that were already included in Django? (i.e. should I write
everything from scratch?)

Thanks.

On Jul 11, 9:54 am, Michał Sawicz  wrote:
> Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > How do I use a foreign key, though? In other words, how do I tell my
> > code to look at UserProfile rather than just user?
>
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> --
> Michał (Saviq) Sawicz 
>
>  signature.asc
> < 1KViewDownload

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
All you have to do is add the following code to your models.py (or any other
module that gets loaded by django, for that matter):

# models.py
from django.db.models import signals

def create_user_profile(sender, instance, created, **kwargs):
 if created:
UserProfile.objects.create(user=instance)

signals.post_save.connect(create_user_profile, sender=User)

(assuming your profile model is called UserProfile, of course).

When django loads models.py, it will call that connect() method which in
turn makes create_user_profile get called every time the sender model (User)
is saved (hence the 'post_save').

More on this at https://docs.djangoproject.com/en/dev/ref/signals/


Cheers,
André Terra

On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:

> I am having trouble with this line of the tutorial: "You need to
> register a handler for the signal django.db.models.signals.post_save
> on the User model, and, in the handler, if created=True, create the
> associated user profile."
>
> It seems I need to edit the User model. I am confused, though, because
> I am using the User model included in django.contrib, and I am very
> hesitant to edit files that are not in my project directory.
>
> Is this bad design to be using a mix of things I've written on my own,
> and things that were already included in Django? (i.e. should I write
> everything from scratch?)
>
> Thanks.
>
> On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > How do I use a foreign key, though? In other words, how do I tell my
> > > code to look at UserProfile rather than just user?
> >
> > https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
> >
> > --
> > Michał (Saviq) Sawicz 
> >
> >  signature.asc
> > < 1KViewDownload
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Pass user.get_profile() as a template variable instead by adding it to the
template context.


Cheers,
André

On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:

> Okay, thanks. This is really helpful.
>
> I am having trouble calling get_profile() from within my profile.html
> template, though. Here is my stack trace:
>
> http://dpaste.com/566583/
>
> I tried calling get_profile without the (), which got rid of the
> error, but no data showed up.
>
> On Jul 11, 10:15 am, Andre Terra  wrote:
> > All you have to do is add the following code to your models.py (or any
> other
> > module that gets loaded by django, for that matter):
> >
> > # models.py
> > from django.db.models import signals
> >
> > def create_user_profile(sender, instance, created, **kwargs):
> >  if created:
> > UserProfile.objects.create(user=instance)
> >
> > signals.post_save.connect(create_user_profile, sender=User)
> >
> > (assuming your profile model is called UserProfile, of course).
> >
> > When django loads models.py, it will call that connect() method which in
> > turn makes create_user_profile get called every time the sender model
> (User)
> > is saved (hence the 'post_save').
> >
> > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
> >
> > Cheers,
> > André Terra
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > I am having trouble with this line of the tutorial: "You need to
> > > register a handler for the signal django.db.models.signals.post_save
> > > on the User model, and, in the handler, if created=True, create the
> > > associated user profile."
> >
> > > It seems I need to edit the User model. I am confused, though, because
> > > I am using the User model included in django.contrib, and I am very
> > > hesitant to edit files that are not in my project directory.
> >
> > > Is this bad design to be using a mix of things I've written on my own,
> > > and things that were already included in Django? (i.e. should I write
> > > everything from scratch?)
> >
> > > Thanks.
> >
> > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > How do I use a foreign key, though? In other words, how do I tell
> my
> > > > > code to look at UserProfile rather than just user?
> >
> > > >
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
> >
> > > > --
> > > > Michał (Saviq) Sawicz 
> >
> > > >  signature.asc
> > > > < 1KViewDownload
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Okay, thanks. This is really helpful.

I am having trouble calling get_profile() from within my profile.html
template, though. Here is my stack trace:

http://dpaste.com/566583/

I tried calling get_profile without the (), which got rid of the
error, but no data showed up.

On Jul 11, 10:15 am, Andre Terra  wrote:
> All you have to do is add the following code to your models.py (or any other
> module that gets loaded by django, for that matter):
>
> # models.py
> from django.db.models import signals
>
> def create_user_profile(sender, instance, created, **kwargs):
>      if created:
>         UserProfile.objects.create(user=instance)
>
> signals.post_save.connect(create_user_profile, sender=User)
>
> (assuming your profile model is called UserProfile, of course).
>
> When django loads models.py, it will call that connect() method which in
> turn makes create_user_profile get called every time the sender model (User)
> is saved (hence the 'post_save').
>
> More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> Cheers,
> André Terra
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > I am having trouble with this line of the tutorial: "You need to
> > register a handler for the signal django.db.models.signals.post_save
> > on the User model, and, in the handler, if created=True, create the
> > associated user profile."
>
> > It seems I need to edit the User model. I am confused, though, because
> > I am using the User model included in django.contrib, and I am very
> > hesitant to edit files that are not in my project directory.
>
> > Is this bad design to be using a mix of things I've written on my own,
> > and things that were already included in Django? (i.e. should I write
> > everything from scratch?)
>
> > Thanks.
>
> > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > How do I use a foreign key, though? In other words, how do I tell my
> > > > code to look at UserProfile rather than just user?
>
> > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> > > --
> > > Michał (Saviq) Sawicz 
>
> > >  signature.asc
> > > < 1KViewDownload
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Is this done in urls.py?

On Jul 11, 10:55 am, Andre Terra  wrote:
> Pass user.get_profile() as a template variable instead by adding it to the
> template context.
>
> Cheers,
> André
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > Okay, thanks. This is really helpful.
>
> > I am having trouble calling get_profile() from within my profile.html
> > template, though. Here is my stack trace:
>
> >http://dpaste.com/566583/
>
> > I tried calling get_profile without the (), which got rid of the
> > error, but no data showed up.
>
> > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > All you have to do is add the following code to your models.py (or any
> > other
> > > module that gets loaded by django, for that matter):
>
> > > # models.py
> > > from django.db.models import signals
>
> > > def create_user_profile(sender, instance, created, **kwargs):
> > >      if created:
> > >         UserProfile.objects.create(user=instance)
>
> > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > (assuming your profile model is called UserProfile, of course).
>
> > > When django loads models.py, it will call that connect() method which in
> > > turn makes create_user_profile get called every time the sender model
> > (User)
> > > is saved (hence the 'post_save').
>
> > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > Cheers,
> > > André Terra
>
> > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > I am having trouble with this line of the tutorial: "You need to
> > > > register a handler for the signal django.db.models.signals.post_save
> > > > on the User model, and, in the handler, if created=True, create the
> > > > associated user profile."
>
> > > > It seems I need to edit the User model. I am confused, though, because
> > > > I am using the User model included in django.contrib, and I am very
> > > > hesitant to edit files that are not in my project directory.
>
> > > > Is this bad design to be using a mix of things I've written on my own,
> > > > and things that were already included in Django? (i.e. should I write
> > > > everything from scratch?)
>
> > > > Thanks.
>
> > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > How do I use a foreign key, though? In other words, how do I tell
> > my
> > > > > > code to look at UserProfile rather than just user?
>
> >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> > > > > --
> > > > > Michał (Saviq) Sawicz 
>
> > > > >  signature.asc
> > > > > < 1KViewDownload
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
This is done in your view:

https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext


Cheers

On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:

> Is this done in urls.py?
>
> On Jul 11, 10:55 am, Andre Terra  wrote:
> > Pass user.get_profile() as a template variable instead by adding it to
> the
> > template context.
> >
> > Cheers,
> > André
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > Okay, thanks. This is really helpful.
> >
> > > I am having trouble calling get_profile() from within my profile.html
> > > template, though. Here is my stack trace:
> >
> > >http://dpaste.com/566583/
> >
> > > I tried calling get_profile without the (), which got rid of the
> > > error, but no data showed up.
> >
> > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > All you have to do is add the following code to your models.py (or
> any
> > > other
> > > > module that gets loaded by django, for that matter):
> >
> > > > # models.py
> > > > from django.db.models import signals
> >
> > > > def create_user_profile(sender, instance, created, **kwargs):
> > > >  if created:
> > > > UserProfile.objects.create(user=instance)
> >
> > > > signals.post_save.connect(create_user_profile, sender=User)
> >
> > > > (assuming your profile model is called UserProfile, of course).
> >
> > > > When django loads models.py, it will call that connect() method which
> in
> > > > turn makes create_user_profile get called every time the sender model
> > > (User)
> > > > is saved (hence the 'post_save').
> >
> > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
> >
> > > > Cheers,
> > > > André Terra
> >
> > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > register a handler for the signal
> django.db.models.signals.post_save
> > > > > on the User model, and, in the handler, if created=True, create the
> > > > > associated user profile."
> >
> > > > > It seems I need to edit the User model. I am confused, though,
> because
> > > > > I am using the User model included in django.contrib, and I am very
> > > > > hesitant to edit files that are not in my project directory.
> >
> > > > > Is this bad design to be using a mix of things I've written on my
> own,
> > > > > and things that were already included in Django? (i.e. should I
> write
> > > > > everything from scratch?)
> >
> > > > > Thanks.
> >
> > > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > > > How do I use a foreign key, though? In other words, how do I
> tell
> > > my
> > > > > > > code to look at UserProfile rather than just user?
> >
> > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> ..
> >
> > > > > > --
> > > > > > Michał (Saviq) Sawicz 
> >
> > > > > >  signature.asc
> > > > > > < 1KViewDownload
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com
> .
> > > > > To unsubscribe from this group, send email to
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Django job, King of Prussia, PA, USA

2011-07-11 Thread Shawn Milochik

http://bit.ly/pAJc4N (Dice.com link)

We're hiring! If you're local check it out, e-mail me with questions.

Thanks,
Shawn

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
So I need to create a custom view? (I can't use an existing view)? I
was hoping to avoid diving into templates until later, after I've
become a little more familiar with the python/html code.

On Jul 11, 11:48 am, Andre Terra  wrote:
> This is done in your view:
>
> https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-...
>
> Cheers
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > Is this done in urls.py?
>
> > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > Pass user.get_profile() as a template variable instead by adding it to
> > the
> > > template context.
>
> > > Cheers,
> > > André
>
> > > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > > Okay, thanks. This is really helpful.
>
> > > > I am having trouble calling get_profile() from within my profile.html
> > > > template, though. Here is my stack trace:
>
> > > >http://dpaste.com/566583/
>
> > > > I tried calling get_profile without the (), which got rid of the
> > > > error, but no data showed up.
>
> > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > All you have to do is add the following code to your models.py (or
> > any
> > > > other
> > > > > module that gets loaded by django, for that matter):
>
> > > > > # models.py
> > > > > from django.db.models import signals
>
> > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > >      if created:
> > > > >         UserProfile.objects.create(user=instance)
>
> > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > When django loads models.py, it will call that connect() method which
> > in
> > > > > turn makes create_user_profile get called every time the sender model
> > > > (User)
> > > > > is saved (hence the 'post_save').
>
> > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > Cheers,
> > > > > André Terra
>
> > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > > register a handler for the signal
> > django.db.models.signals.post_save
> > > > > > on the User model, and, in the handler, if created=True, create the
> > > > > > associated user profile."
>
> > > > > > It seems I need to edit the User model. I am confused, though,
> > because
> > > > > > I am using the User model included in django.contrib, and I am very
> > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > Is this bad design to be using a mix of things I've written on my
> > own,
> > > > > > and things that were already included in Django? (i.e. should I
> > write
> > > > > > everything from scratch?)
>
> > > > > > Thanks.
>
> > > > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > How do I use a foreign key, though? In other words, how do I
> > tell
> > > > my
> > > > > > > > code to look at UserProfile rather than just user?
>
> > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > ..
>
> > > > > > > --
> > > > > > > Michał (Saviq) Sawicz 
>
> > > > > > >  signature.asc
> > > > > > > < 1KViewDownload
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Django users" group.
> > > > > > To post to this group, send email to django-users@googlegroups.com
> > .
> > > > > > To unsubscribe from this group, send email to
> > > > > > django-users+unsubscr...@googlegroups.com.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/django-users?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Sorry, I meant I was hoping to avoid diving into defining my own views
until later.

On Jul 11, 1:08 pm, Brent  wrote:
> So I need to create a custom view? (I can't use an existing view)? I
> was hoping to avoid diving into templates until later, after I've
> become a little more familiar with the python/html code.
>
> On Jul 11, 11:48 am, Andre Terra  wrote:
>
>
>
>
>
>
>
> > This is done in your view:
>
> >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-...
>
> > Cheers
>
> > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > Is this done in urls.py?
>
> > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > Pass user.get_profile() as a template variable instead by adding it to
> > > the
> > > > template context.
>
> > > > Cheers,
> > > > André
>
> > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > > > Okay, thanks. This is really helpful.
>
> > > > > I am having trouble calling get_profile() from within my profile.html
> > > > > template, though. Here is my stack trace:
>
> > > > >http://dpaste.com/566583/
>
> > > > > I tried calling get_profile without the (), which got rid of the
> > > > > error, but no data showed up.
>
> > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > All you have to do is add the following code to your models.py (or
> > > any
> > > > > other
> > > > > > module that gets loaded by django, for that matter):
>
> > > > > > # models.py
> > > > > > from django.db.models import signals
>
> > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > >      if created:
> > > > > >         UserProfile.objects.create(user=instance)
>
> > > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > > When django loads models.py, it will call that connect() method 
> > > > > > which
> > > in
> > > > > > turn makes create_user_profile get called every time the sender 
> > > > > > model
> > > > > (User)
> > > > > > is saved (hence the 'post_save').
>
> > > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > > Cheers,
> > > > > > André Terra
>
> > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > > > register a handler for the signal
> > > django.db.models.signals.post_save
> > > > > > > on the User model, and, in the handler, if created=True, create 
> > > > > > > the
> > > > > > > associated user profile."
>
> > > > > > > It seems I need to edit the User model. I am confused, though,
> > > because
> > > > > > > I am using the User model included in django.contrib, and I am 
> > > > > > > very
> > > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > > Is this bad design to be using a mix of things I've written on my
> > > own,
> > > > > > > and things that were already included in Django? (i.e. should I
> > > write
> > > > > > > everything from scratch?)
>
> > > > > > > Thanks.
>
> > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > > How do I use a foreign key, though? In other words, how do I
> > > tell
> > > > > my
> > > > > > > > > code to look at UserProfile rather than just user?
>
> > > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > ..
>
> > > > > > > > --
> > > > > > > > Micha³ (Saviq) Sawicz 
>
> > > > > > > >  signature.asc
> > > > > > > > < 1KViewDownload
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the Google
> > > > > Groups
> > > > > > > "Django users" group.
> > > > > > > To post to this group, send email to django-users@googlegroups.com
> > > .
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > django-users+unsubscr...@googlegroups.com.
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/django-users?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this g

Re: Scaling to 30k requests (malcolm box blog)

2011-07-11 Thread Leonidas Tsampros
"Cal Leeming [Simplicity Media Ltd]"
 writes:
> Came across the following blog entries today, for those interested in this
> sort of thing:
>
> http://attentionshard.wordpress.com/2011/04/26/scaling-django-to-3-requests-per-second/
>
> http://attentionshard.wordpress.com/2011/04/03/scaling-to-30k-two-level-caches/
> Interesting approach. Although you'd have to be careful what context it was
> used in (i.e. if your code is written under the assumption that the caching
> server is atomic).
>
> http://attentionshard.wordpress.com/2011/04/26/scaling-to-30k-tsung/
> Never heard of tsung before, looks pretty nice. Will try it out for sure.
>
> http://attentionshard.wordpress.com/2011/05/03/scaling-to-30k-haproxy-on-ec2/
> Can't comment much on this, as we've never used haproxy.
>
> The stack they have used is quite interesting. Although they are using
> Apache w/ mod_wsgi (which tends to be a lot slower than using nginx with
> uwsgi), they still seem to have got some decent performance out of it.
>
> http://attentionshard.wordpress.com/2011/06/21/behind-the-scenes-using-cassandra-acunu-to-power-britains-got-talent/
> Explains a bit of their usage of using Cassandra. Would be interesting to
> see some benchmarks though.
>
> Cal

Hi Cal,

really thanks for sharing these posts!


Malcolm Box  writes:

> Thanks for the recommendations Cal. I hope this stuff is of use to some
> people - let me know if anyone wants to know more.
>
> On 10 July 2011 21:06, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Came across the following blog entries today, for those interested in this
>> sort of thing:
>>
>>
>> http://attentionshard.wordpress.com/2011/04/26/scaling-django-to-3-requests-per-second/
>>
>>
>> http://attentionshard.wordpress.com/2011/04/03/scaling-to-30k-two-level-caches/
>> Interesting approach. Although you'd have to be careful what context it was
>> used in (i.e. if your code is written under the assumption that the caching
>> server is atomic).
>>
>
> Actually atomicity is preserved for updates, as all updates go to the L2
> cache servers (so are as atomic as memcache over multiple servers is). The
> main gotcha is that you have to be happy that different servers can have
> values that are up to N seconds out of date - but generally that's not too
> bad, as it's pretty much the same situation as using a reverse proxy cache.
>
>
>>
>> http://attentionshard.wordpress.com/2011/04/26/scaling-to-30k-tsung/
>> Never heard of tsung before, looks pretty nice. Will try it out for sure.
>>
>>
> Can't recommend Tsung highly enough. It Just Works for testing large numbers
> of concurrent connections, which is more than I can say for other tools I've
> tried (apachebench, JMeter, swarm of bees). There's several companies around
> that offer to do high load testing but last time I checked their rates were
> sky-high.

+1. Tsung was maybe the only tool fit for this kind of testing, a while
back, when I was doing some scaling tests.

>
>
>> The stack they have used is quite interesting. Although they are using
>> Apache w/ mod_wsgi (which tends to be a lot slower than using nginx with
>> uwsgi), they still seem to have got some decent performance out of it.
>
>
> Indeed, it's on the to-do list to try comparing the performance of
> Apache/mod_wsgi with nginx/uwsgi, but my gut feel is that the webserver +
> WSGI container makes only a marginal difference to the overall site
> performance. Of course, I Could Be Wrong.
>

I had exactly the same thoughts although I'm just intrested (out of
plain curiosity) in how nginx/uwsgi scales with and without the caching
framework.

It would be intresting though to see the difference between the two
stacks.

>>
>>
>> http://attentionshard.wordpress.com/2011/06/21/behind-the-scenes-using-cassandra-acunu-to-power-britains-got-talent/
>> Explains a bit of their usage of using Cassandra. Would be interesting to
>> see some benchmarks though.
>>
>
> What benchmarks would you like to see? We sustained 10K writes/second into a
> 2 node m1.large cluster if that helps.
>
> Malcolm

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



Django Auth

2011-07-11 Thread Gizmo
please  am new to django, and am looking for something more
appropriate for django auth

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



Re: Need help intercepting SQL

2011-07-11 Thread bruno desthuilliers
On 11 juil, 16:47, Eric B  wrote:
> > @OP: I think your better bet would be to implement your own db
> > backend, deriving from django's mysql backend.
>
> I agree and looked into this, but the backend in Django 1.2 actually
> defers to the MySQLdb library.

Of course it does - MySQLdb is the "official" (well, almost) db-api
compliant MySQL binding. Now you asked for "the best way to intercept
the raw SQL sent to the database", and since it's the mysqldb backend
that generates and sends the raw SQL it's still the best place to add
your own code AFAICT.

>  I couldn't find any references online
> that talked about or showed examples for extending a database
> backend.  If you know of any, I would really appropriate it if you
> could post the link(s).


I'm afraid you'll have to use the code, Luke - at least you have a
working example.

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
You could use a context processor, which is basically a function that adds
variables to *every* template that gets called from a properly setup view. I
assume the view you are using does apply context processors, and defining
one is as easy as:

http://stackoverflow.com/questions/3722174/django-template-inheritance-and-context/3731459#3731459

You can try step #3 once you feel confident enough to write views (they are
very simple!)


Cheers,
André Terra (airstrike)

On Mon, Jul 11, 2011 at 5:12 PM, Brent  wrote:

> Sorry, I meant I was hoping to avoid diving into defining my own views
> until later.
>
> On Jul 11, 1:08 pm, Brent  wrote:
> > So I need to create a custom view? (I can't use an existing view)? I
> > was hoping to avoid diving into templates until later, after I've
> > become a little more familiar with the python/html code.
> >
> > On Jul 11, 11:48 am, Andre Terra  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > This is done in your view:
> >
> > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-.
> ..
> >
> > > Cheers
> >
> > > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > > Is this done in urls.py?
> >
> > > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > > Pass user.get_profile() as a template variable instead by adding it
> to
> > > > the
> > > > > template context.
> >
> > > > > Cheers,
> > > > > André
> >
> > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent 
> wrote:
> > > > > > Okay, thanks. This is really helpful.
> >
> > > > > > I am having trouble calling get_profile() from within my
> profile.html
> > > > > > template, though. Here is my stack trace:
> >
> > > > > >http://dpaste.com/566583/
> >
> > > > > > I tried calling get_profile without the (), which got rid of the
> > > > > > error, but no data showed up.
> >
> > > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > > All you have to do is add the following code to your models.py
> (or
> > > > any
> > > > > > other
> > > > > > > module that gets loaded by django, for that matter):
> >
> > > > > > > # models.py
> > > > > > > from django.db.models import signals
> >
> > > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > > >  if created:
> > > > > > > UserProfile.objects.create(user=instance)
> >
> > > > > > > signals.post_save.connect(create_user_profile, sender=User)
> >
> > > > > > > (assuming your profile model is called UserProfile, of course).
> >
> > > > > > > When django loads models.py, it will call that connect() method
> which
> > > > in
> > > > > > > turn makes create_user_profile get called every time the sender
> model
> > > > > > (User)
> > > > > > > is saved (hence the 'post_save').
> >
> > > > > > > More on this athttps://
> docs.djangoproject.com/en/dev/ref/signals/
> >
> > > > > > > Cheers,
> > > > > > > André Terra
> >
> > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent 
> wrote:
> > > > > > > > I am having trouble with this line of the tutorial: "You need
> to
> > > > > > > > register a handler for the signal
> > > > django.db.models.signals.post_save
> > > > > > > > on the User model, and, in the handler, if created=True,
> create the
> > > > > > > > associated user profile."
> >
> > > > > > > > It seems I need to edit the User model. I am confused,
> though,
> > > > because
> > > > > > > > I am using the User model included in django.contrib, and I
> am very
> > > > > > > > hesitant to edit files that are not in my project directory.
> >
> > > > > > > > Is this bad design to be using a mix of things I've written
> on my
> > > > own,
> > > > > > > > and things that were already included in Django? (i.e. should
> I
> > > > write
> > > > > > > > everything from scratch?)
> >
> > > > > > > > Thanks.
> >
> > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > > > > > > How do I use a foreign key, though? In other words, how
> do I
> > > > tell
> > > > > > my
> > > > > > > > > > code to look at UserProfile rather than just user?
> >
> > > > > >
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > > ..
> >
> > > > > > > > > --
> > > > > > > > > Micha³ (Saviq) Sawicz 
> >
> > > > > > > > >  signature.asc
> > > > > > > > > < 1KViewDownload
> >
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> Google
> > > > > > Groups
> > > > > > > > "Django users" group.
> > > > > > > > To post to this group, send email to
> django-users@googlegroups.com
> > > > .
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > django-users+unsubscr...@googlegroups.com.
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/django-users?hl=en.
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > Groups
> > > > > > "Django users" group.
> > > > > > To post to this group, send email to
> djan

Adding errors to form after successful validation

2011-07-11 Thread Brian McKeever
I have a search form that is used by a view to search for results and
then redirect to display them one at a time. If my search doesn't find
any objects matching the criteria, I'd like to display a message
saying so.

It seems natural to add this error to the search form and redisplay it
since it already displays error with the search.

Is there an easy way to do this, or should I be doing something else
because a failed database query is not a form error?

I've been trying to do this:
form.non_field_errors().append(forms.ValidationError("No roblems found
matching that criteria"))
but it doesn't work (non_field_errors() is not well documented).

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



Re: Adding errors to form after successful validation

2011-07-11 Thread Andre Terra
I feel your pain, validating forms can be a PITA... Try reading through this
last bit of the form validation docs:

https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other


Cheers,
André Terra

On Mon, Jul 11, 2011 at 6:02 PM, Brian McKeever  wrote:

> I have a search form that is used by a view to search for results and
> then redirect to display them one at a time. If my search doesn't find
> any objects matching the criteria, I'd like to display a message
> saying so.
>
> It seems natural to add this error to the search form and redisplay it
> since it already displays error with the search.
>
> Is there an easy way to do this, or should I be doing something else
> because a failed database query is not a form error?
>
> I've been trying to do this:
> form.non_field_errors().append(forms.ValidationError("No roblems found
> matching that criteria"))
> but it doesn't work (non_field_errors() is not well documented).
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django 1.3, Apache/2.2.14, mod_wsgi/2.8 Python/2.6.5 mod_wsgi (pid=6676): Unable to get bucket brigade for request

2011-07-11 Thread Serial H.
Hello,

Did you find the solution ? I have exactly the same configuration but
I am using Ubuntu 10.04.

Serial H.

On Jun 16, 11:56 pm, chycyra  wrote:
> sorry for error typing: the server is Ubuntu 10.04 and i'm no using
> HTTPS request
>
> On Jun 17, 9:14 am, Heru Eko Susanto  wrote:
>
>
>
>
>
>
>
> > hello all,
>
> > i'm using Apache + mod_wsgi on ubuntu 9.10 . today i have error on my
> > server:
>
> > [Tue Jun 14 06:27:49 2011] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/2.8
> > Python/2.6.5 configured -- resuming normal operations
> > [Fri Jun 17 07:29:57 2011] [error] [client 192.168.1.4] (70007)The timeout
> > specified has expired: mod_wsgi (pid=6676): Unable to get bucket brigade for
> > request., referer:http://192.168.1.6/admin/master/tarip/add/
> > [Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] mod_wsgi (pid=6675):
> > Exception occurred processing WSGI script
> > '/var/www/nakula/wsgi/billing.wsgi'.
> > [Fri Jun 17 07:29:59 2011] [error] [client 192.168.1.4] IOError: failed to
> > write data
>
> > here apache conf for the server:
>
> > 
> >     ServerName wsgi.djangoserver
> >     DocumentRoot /var/www/nakula
>
> >     
> >         Order allow,deny
> >         Allow from all
> >     
> >     WSGIDaemonProcess nakula.djangoserver processes=2 threads=15
> > display-name=%{GRUP}
> >     WSGIProcessGroup nakula.djangoserver
>
> >     WSGIScriptAlias / /var/www/nakula/wsgi/billing.wsgi
> > 
>
> > and billing.wsgi:
>
> > import os
> > import sys
> > path = '/var/www/nakula'
> > if path not in sys.path:
> >     sys.path.insert(0,path)
> > os.environ['DJANGO_SETTINGS_MODULE']='settings'
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > did I missed some configuration ? or any suggestion for this problem ?
>
> > Thank you,
>
> > heru

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



Re: speeding up iterating over query set

2011-07-11 Thread bruno desthuilliers
On 11 juil, 15:57, Michel30  wrote:
> Hi all,
>
> I have a basic search function that uses Q objects.
> After profiling it I found that the actual (mysql) database query
> finishes in fractions of seconds but the iterating after this can take
> up to 50 seconds per 10.000 results.
>
> I have been trying to speed it up but I have had not much results..
>
> My query is this one:
>
>        found_entries = model.objects.filter((Q-objects),
> obsolete=0).order_by('-version','docid')
>
> So far so good, but then I need a dictionary to retrieve only unique
> 'documentid's'.
>
>     rev_dict = {}
>
> This is the part that hurts:
>
>     for d in found_entries:
>         rev_dict[d.documentid] = d



> And then some more sorting and filtering:
>
>     filtered_entries = rev_dict.values()
>     filtered_entries.sort(key=lambda d: d.revisiondate, reverse=True)
>
> Does anyone have some better ideas to achieve this?

Ok, so what you want is a queryset of "model" with distinct docid
having the highest version number, sorted by revisiondate ? The
cleanest solution would be to first write the appropriate SQL query,
then find out how to express it using django. FWIW, the raw SQL query
might look like this (MySQL):

mysql> select f1.pk, f1.docid, f1.version, f1.revisiondate from foo f1
where f1.version=(select max(f2.version) from foo f2 where
f2.docid=f1.docid) order by revisiondate desc;
++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  7 | 3 |   2 | 2000-02-12   |
|  6 | 1 |   2 | 2000-02-11   |
|  5 | 2 |   3 | 2000-02-10   |
++---+-+--+
3 rows in set (0.00 sec)

NB: table definition and date being:

mysql> explain foo;
+--+-+--+-+-++
| Field| Type| Null | Key | Default | Extra  |
+--+-+--+-+-++
| pk   | int(11) | NO   | PRI | NULL| auto_increment |
| docid| int(11) | NO   | | NULL||
| version  | int(11) | NO   | | NULL||
| revisiondate | date| NO   | | NULL||
+--+-+--+-+-++

mysql> select * from foo;
++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  1 | 1 |   1 | 2000-01-01   |
|  2 | 2 |   1 | 2000-01-02   |
|  3 | 3 |   1 | 2000-01-02   |
|  4 | 2 |   2 | 2000-02-10   |
|  5 | 2 |   3 | 2000-02-10   |
|  6 | 1 |   2 | 2000-02-11   |
|  7 | 3 |   2 | 2000-02-12   |
++---+-+--+
7 rows in set (0.00 sec)


NB: Adding indexes on docid and/or version might help (or damage)
performances, depending on your data set.

Now you just have to learn how to use django's orm F, max and extra.
Or, for a simpler solution (but less portable) solution, use a raw SQL
query to only retrieve distinct pk then a second query to build the
whole queryset, ie:

from django.db import connection

def get_latest_revisions():
cursor = connection.cursor()
cursor.execute("""
SELECT DISTINCT f1.pk  FROM foo as f1
WHERE f1.version=(SELECT max(f2.version) FROM foo f2 WHERE
f2.docid=f1.docid)
""")
ids = [row[0] for row in cursor] # or is it "row['pk']" ???
cursor.close()
return model.objects.filter(pk__in=ids).order_by("-revision_date")

This might possibly be done using
manager.raw(your_sql_here).values_list("pk", flat=True) to build the
pk list, but I have never used RawQuerySets so far and the doc doesn't
tell if RawQuerySet supports values_list so you'll have to try by
yourself.

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



TransactionTestCase and Fixture Teardown

2011-07-11 Thread David Cramer
We're currently in the process of converting from unittest (pure) to
Nose, and one of the issues I've noticed while doing this was that the
database wasn't flushing correctly when switching from a
TransactionTestCase to a TestCase. I've been digging through the code
this morning, and I honestly can't even figure out how this would work
in the standard test suite (excluding nose).

I can't imagine this is an actual bug, or that it only came up for
Nose, so I'm hoping someone can explain if there is magic somewhere in
here, and where it is. Otherwise I suppose I can file an awful ticket
to add flush to the teardown step as well (which is what I temporarily
did to move past this problem).

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



Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Hmm...I see. How do you choose what variables are available to which
view? It seems like anything I put in context_processors is available
anywhere, and I'm not sure I want that.

I think I am getting closer, but I am now getting a
SiteProfileNotAvailable error.

Here is my stack trace:

http://dpaste.com/566744/

Thanks for the help.

On Jul 11, 2:01 pm, Andre Terra  wrote:
> You could use a context processor, which is basically a function that adds
> variables to *every* template that gets called from a properly setup view. I
> assume the view you are using does apply context processors, and defining
> one is as easy as:
>
> http://stackoverflow.com/questions/3722174/django-template-inheritanc...
>
> You can try step #3 once you feel confident enough to write views (they are
> very simple!)
>
> Cheers,
> André Terra (airstrike)
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 5:12 PM, Brent  wrote:
> > Sorry, I meant I was hoping to avoid diving into defining my own views
> > until later.
>
> > On Jul 11, 1:08 pm, Brent  wrote:
> > > So I need to create a custom view? (I can't use an existing view)? I
> > > was hoping to avoid diving into templates until later, after I've
> > > become a little more familiar with the python/html code.
>
> > > On Jul 11, 11:48 am, Andre Terra  wrote:
>
> > > > This is done in your view:
>
> > > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-.
> > ..
>
> > > > Cheers
>
> > > > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > > > Is this done in urls.py?
>
> > > > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > > > Pass user.get_profile() as a template variable instead by adding it
> > to
> > > > > the
> > > > > > template context.
>
> > > > > > Cheers,
> > > > > > André
>
> > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent 
> > wrote:
> > > > > > > Okay, thanks. This is really helpful.
>
> > > > > > > I am having trouble calling get_profile() from within my
> > profile.html
> > > > > > > template, though. Here is my stack trace:
>
> > > > > > >http://dpaste.com/566583/
>
> > > > > > > I tried calling get_profile without the (), which got rid of the
> > > > > > > error, but no data showed up.
>
> > > > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > > > All you have to do is add the following code to your models.py
> > (or
> > > > > any
> > > > > > > other
> > > > > > > > module that gets loaded by django, for that matter):
>
> > > > > > > > # models.py
> > > > > > > > from django.db.models import signals
>
> > > > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > > > >      if created:
> > > > > > > >         UserProfile.objects.create(user=instance)
>
> > > > > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > > > > When django loads models.py, it will call that connect() method
> > which
> > > > > in
> > > > > > > > turn makes create_user_profile get called every time the sender
> > model
> > > > > > > (User)
> > > > > > > > is saved (hence the 'post_save').
>
> > > > > > > > More on this athttps://
> > docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > > > > Cheers,
> > > > > > > > André Terra
>
> > > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent 
> > wrote:
> > > > > > > > > I am having trouble with this line of the tutorial: "You need
> > to
> > > > > > > > > register a handler for the signal
> > > > > django.db.models.signals.post_save
> > > > > > > > > on the User model, and, in the handler, if created=True,
> > create the
> > > > > > > > > associated user profile."
>
> > > > > > > > > It seems I need to edit the User model. I am confused,
> > though,
> > > > > because
> > > > > > > > > I am using the User model included in django.contrib, and I
> > am very
> > > > > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > > > > Is this bad design to be using a mix of things I've written
> > on my
> > > > > own,
> > > > > > > > > and things that were already included in Django? (i.e. should
> > I
> > > > > write
> > > > > > > > > everything from scratch?)
>
> > > > > > > > > Thanks.
>
> > > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > > > > How do I use a foreign key, though? In other words, how
> > do I
> > > > > tell
> > > > > > > my
> > > > > > > > > > > code to look at UserProfile rather than just user?
>
> >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > > > ..
>
> > > > > > > > > > --
> > > > > > > > > > Micha³ (Saviq) Sawicz 
>
> > > > > > > > > >  signature.asc
> > > > > > > > > > < 1KViewDownload
>
> > > > > > > > > --
> > > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > Groups
> > > > > > > > > "Django users" group.
> > > > > > > > > To post to this group, send email to
> > dj

Re: Adding errors to form after successful validation

2011-07-11 Thread Brian McKeever
I am now doing my query in the form's clean method, and it errors the
way I want it to. Thank you.

Although, I do feel dirty doing it this way. I feel like I should be
able to append an error to the form in the view.

On Jul 11, 3:04 pm, Andre Terra  wrote:
> I feel your pain, validating forms can be a PITA... Try reading through this
> last bit of the form validation docs:
>
> https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-...
>
> Cheers,
> André Terra
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 6:02 PM, Brian McKeever  wrote:
> > I have a search form that is used by a view to search for results and
> > then redirect to display them one at a time. If my search doesn't find
> > any objects matching the criteria, I'd like to display a message
> > saying so.
>
> > It seems natural to add this error to the search form and redisplay it
> > since it already displays error with the search.
>
> > Is there an easy way to do this, or should I be doing something else
> > because a failed database query is not a form error?
>
> > I've been trying to do this:
> > form.non_field_errors().append(forms.ValidationError("No roblems found
> > matching that criteria"))
> > but it doesn't work (non_field_errors() is not well documented).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Django 1.3, Apache/2.2.14, mod_wsgi/2.8 Python/2.6.5 mod_wsgi (pid=6676): Unable to get bucket brigade for request

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]

Come on guys, at least make some effort to use Google :/

http://stackoverflow.com/questions/4557920/why-is-mod-wsgi-not-able-to-write-data-ioerror-failed-to-write-data

http://stackoverflow.com/questions/4517397/print-statements-on-server-give-ioerror-failed-to-write-data

http://forum.webfaction.com/viewtopic.php?id=3619

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598143

http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=%22IOError%3A+failed+to+write+data%22 



Perhaps review those links, see what you can figure out, and let us know 
how far you get..?


Cal

On 17/06/2011 03:14, Heru Eko Susanto wrote:

IOError: failed to write data


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



Re: Django Auth

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]

Hi,

Please refer to http://code.djangoproject.com/wiki/UsingTheMailingList 
when using the mailing list in the future.


To answer your question, I believe what you are looking for is:

https://docs.djangoproject.com/en/dev/topics/auth/

Cal

On 11/07/2011 20:45, Gizmo wrote:

please  am new to django, and am looking for something more
appropriate for django auth



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



Django form validation.. does anyone else find it awkward??

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Does anyone else find working with form validation in Django to be a bit 
awkward and/or tedious?


I can't say exactly why I don't like it, because I don't really know 
myself, I just always disliked working with it.


Am I being a fussy little fuzz ball, or does anyone else have this same 
view towards it..?


Cal

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



Re: need help with calling following complex query

2011-07-11 Thread sanket
Thanks @Venkatraman, I really appreciate your help.
ability to create a function is pretty cool.

Thanks again,
sanket

On Jul 11, 1:06 pm, Jonas Geiregat  wrote:
> > results.extra(select={
> >                             'distance': 
> > '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(latitude)f)*cos(%(longitude)f-longitude)))'
> >   % {
> >                                  'latitude': latitude,
> >                                  'longitude': longitude
> >                             }
> >                         }).order_by('distance')  
>
> This is an interesting solution to the issue. I never really looked into the 
> extra method.
> So I read the docs and I'm wondering if it wouldn't be better to use the 
> select_params parameter ?

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



Problem loading admin static files

2011-07-11 Thread mf
I'm trying to upload my project to the production server but it fails
to load the admin static files.

settings.py:

import os

PROJECT_DIR = os.path.dirname(__file__)

MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

MEDIA_URL = '/media/'

STATIC_ROOT ='/srv/www/antingprojects.com.ar/gobras/static'

STATIC_URL = '/static/'

ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static'),
)

main urls.py:

from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
(r'^media/(?P.*)$', 'django.views.static.serve',
 {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'^admin/', include(admin.site.urls)),
(r'^static/admin/(?P.*)$', 'django.views.static.serve'),
(r'^obras/', include('obras.urls')),
)

nginx.conf(I use nginx with gunicorn):

server {
listen 80;
server_name antingprojects.com.ar;

access_log /srv/www/antingprojects.com.ar/gobras/access.log;
error_log /srv/www/antingprojects.com.ar/gobras/error.log;

location /media {
root /srv/www/antingprojects.com.ar/gobras;
}

location /static {
root /srv/www/antingprojects.com.ar/gobras;
}

location / {
proxy_pass http://127.0.0.1:;
}
}

Project folder: /srv/www/antingprojects.com.ar/gobras/static/admin/
media

access.log(snippet):

 "GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/base.css
HTTP/1.1" 404 1116 "http://antingprojects.com.ar/admin/obras/cliente/?
localidad=CAPITAL+FEDERAL" "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1)
Gecko/20100101 Firefox/4.0.1"

"GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/
changelists.css HTTP/1.1" 404 1119 "http://antingprojects.com.ar/admin/
obras/cliente/?localidad=CAPITAL+FEDERAL" "Mozilla/5.0 (X11; Linux
x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

online site(antingprojects.com.ar):





When I inspect those links with Firebug I can see the css files
correctly loaded. I don't know why it doesn't work.

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



Re: Problem loading admin static files

2011-07-11 Thread Shawn Milochik
It looks like you put STATIC_ROOT in your templates where you should
have used STATIC_URL.

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



Re: TransactionTestCase and Fixture Teardown

2011-07-11 Thread Ramiro Morales
On Mon, Jul 11, 2011 at 6:52 PM, David Cramer  wrote:
> We're currently in the process of converting from unittest (pure) to
> Nose, and one of the issues I've noticed while doing this was that the
> database wasn't flushing correctly when switching from a
> TransactionTestCase to a TestCase. I've been digging through the code
> this morning, and I honestly can't even figure out how this would work
> in the standard test suite (excluding nose).

For our test runner it seems test case [1][2]reordering works in a way
so the TransactionTestCase's go to a bucket after the TestCase's even
when you specify an opposite explicit order. e.g.:

$ ~/django_test/pg83
backends.FkConstraintsTests.test_integrity_checks_on_creation
basic.ModelTest.test_object_creation -v2
[...]
test_object_creation (modeltests.basic.tests.ModelTest) ... ok
test_integrity_checks_on_creation
(regressiontests.backends.tests.FkConstraintsTests) ... ok

--
Ran 2 tests in 1.031s

So there isn't possibility of a TestCase being run after a
TransactionTestCase with our test infrastructure.  I can't say this is
by design or a result of gradual evolution of our test support code.
That's why I'm leaving this note here just in case we want to revisit
this at some point (although I suspect adding a flush at the end of
every test case for MySQL+MyISAM  TransactionTestCase will make it even
slower).

-- 
Ramiro Morales


1. 
https://code.djangoproject.com/browser/django/trunk/django/test/simple.py#L172
2. 
https://code.djangoproject.com/browser/django/trunk/django/test/simple.py#L252

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



Re: Django job, King of Prussia, PA, USA

2011-07-11 Thread Venkatraman S
On Tue, Jul 12, 2011 at 12:38 AM, Shawn Milochik  wrote:

> http://bit.ly/pAJc4N (Dice.com link)
>
> We're hiring! If you're local check it out, e-mail me with questions.
>

Do you consider remote(overseas) candidates?

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



Re: Django form validation.. does anyone else find it awkward??

2011-07-11 Thread Venkatraman S
On Tue, Jul 12, 2011 at 4:26 AM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Does anyone else find working with form validation in Django to be a bit
> awkward and/or tedious?
>
> I can't say exactly why I don't like it, because I don't really know
> myself, I just always disliked working with it.
>
> Am I being a fussy little fuzz ball, or does anyone else have this same
> view towards it..?
>

Well, i had my own cribs w.r.t form rendering ...as_p and as_table looked
neanderthal.
However, i moved to uni-form, and am loving it since then.

On the validation, yes, it is a little pesky. But, offlate, i am trying to
*understand* it better and trying to move the logic
to the client. For eg. jquery-validate does bulk of the stuff on client side
- atleast for required fields. So, moving
bulk of the validation to the client helps in avoiding a few http calls.

-V

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



Re: Django Auth

2011-07-11 Thread Kiril Vladimirov
You might want to search for something that could *expand* Django Auth to 
the way you like it. But trust me, you don't need anything else.

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



Re: Django Auth

2011-07-11 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 12:45 -0700, Gizmo wrote:
> please  am new to django, and am looking for something more
> appropriate for django auth 

what features do you want?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Django job, King of Prussia, PA, USA

2011-07-11 Thread Kenneth Gonsalves
On Tue, 2011-07-12 at 07:00 +0530, Venkatraman S wrote:
> On Tue, Jul 12, 2011 at 12:38 AM, Shawn Milochik 
> wrote:
> 
> > http://bit.ly/pAJc4N (Dice.com link)
> >
> > We're hiring! If you're local check it out, e-mail me with
> questions.
> >
> 
> Do you consider remote(overseas) candidates? 

offlist please
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



get all objects that are related to current, reverse look up

2011-07-11 Thread garagefan
simply put, here's my code

class ContentBlock(Orderable, Displayable):
  location = models.ManyToManyField(ContentBlockLocation, blank=True,
null=True, help_text="list of locations to display content block")
  page = models.ManyToManyField(Page, blank=True, null=True,
help_text="list of pages to display content block")
  height = models.IntegerField(blank=True, null=True)
  width = models.IntegerField(blank=True, null=True)

  def __unicode__(self):
return self.title


class StaticContent(Displayable, RichText):
 content_block =  models.ForeignKey(ContentBlock, blank=True,
null=True)

class StaticContent2(Displayable, RichText):
 content_block =  models.ForeignKey(ContentBlock, blank=True,
null=True)

putting together a template tag that will return all the items
associated with a given ContentBlock, but i would like to do so
without knowing upfront all of the classes that have a foreign key to
ContentBlock as i'll want to be able to add more content types at any
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using the mailing list

2011-07-11 Thread Kenneth Gonsalves
hi,

I think this deserves a thread of it's own. I have started a section on
migrating from other frameworks - since I came from Zope, I have added a
few points there. People from other frameworks/tools please pitch in.

https://code.djangoproject.com/wiki/UsingTheMailingList#Migratingfromotherframeworkstools
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



request.method GET or POST

2011-07-11 Thread Venkatraman S
We have to check for request.method to suitably route the request to the
logic.

Would it be nice if we have something like doGet or doPost(similar to java
servlets) that we have in our views,
so that the request gets automatically routed , and the code is structured
nicely?

So a view would look like:
def funcname(request,itemid,..):
  def doPOST():
#.do things when the request is POST
  def doGET():
#.do things when the request is GET..

Comments? (note that i am not passing request object to individual doPOST or
doGET).

-V-

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



Re: Django job, King of Prussia, PA, USA

2011-07-11 Thread Venkatraman S
On Tue, Jul 12, 2011 at 7:40 AM, Kenneth Gonsalves
wrote:

> On Tue, 2011-07-12 at 07:00 +0530, Venkatraman S wrote:
> > On Tue, Jul 12, 2011 at 12:38 AM, Shawn Milochik 
> > wrote:
> >
> > > http://bit.ly/pAJc4N (Dice.com link)
> > >
> > > We're hiring! If you're local check it out, e-mail me with
> > questions.
> > >
> >
> > Do you consider remote(overseas) candidates?
>
> offlist please
>


Oops! i did not intend to send this to the list; was planning to suggest to
Shawn of making the clause better to avoid spam.(I should have dozed!)
Apologies again.

-V

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



Re: need help with calling following complex query

2011-07-11 Thread Venkatraman S
On Tue, Jul 12, 2011 at 4:36 AM, sanket  wrote:

> Thanks @Venkatraman, I really appreciate your help.
> ability to create a function is pretty cool.
>

Thanks. Actually, i stumbled on this solution due to my use case - i test
all my apps in sqlite3 and then move to other dbs; as it is easy for me to
manage a single db file, and there is no db server overhead . And in this
case, i used the exact same sql excerpt and found that sqlite3 did not
support the math funcs. It was a pretty nifty hack.

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



  1   2   >