Re: Django multiple databases router

2011-03-24 Thread dy
Hi Jacob:

Yes, you understand right!Thank you for your reply.

As you said,is this a bug of django1.2.3? Or this feature can be used
in django-1.2.3, but at a higher version is disabled.

Moreover, in the official documentation(on this page:http://
docs.djangoproject.com/en/1.3/topics/db/multi-db/), I did not see that
django does not support the primary foreign keys across databases.As
you know , sometimes the demand is very strange , so I wonder why I
can use it on django-1.2.3 and not on django-1.2.5 or higher
version .This made me very confused.

Thanks again.

Dy

-- 
You received this message because you are subscribed to the Google 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: Implementing a ldap db backend

2011-03-24 Thread sebastien piquemal
After the initial post, following the advice of many people I didn't
try to implement a backend for ldap... Instead I wrote my own o(r)m -
it supports very basically the same functionalities as django-orm :
foreignkeys, manytomany, inheritance, ...- it is somewhat integrated
with Django (this only means that you can use django settings module).
I think it works quite well, the code is quite simple, even though I
still have a few improvements to make before releasing it. However I
have reached a point where it could indeed be "released", so I'll make
those improvements tomorrow, write what's missing of documentation,
and I'll make an announcement next week on django-users !

Cheers,

Sébastien

On Mar 22, 7:49 pm, "Sells, Fred" 
wrote:
> I'm using my own auth and ldap via python-ldap as a query only; others 
> maintain it.  My only issue is that of response.  I query all the groups I 
> care about and get all their members and keep that in a MySQL db that I 
> refresh every 5 minutes of an unrelated cron job.
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Felipe Prenholato
> Sent: Tuesday, March 22, 2011 9:19 AM
> To: django-users@googlegroups.com
> Subject: Re: Implementing a ldap db backend
>
> I have read and tested some more libs.
>
> My concern is that:
>
> django-ldapdb 
> (http://opensource.bolloretelecom.eu/projects/django-ldapdb/):amazing idea, 
> I'm working very well to query users, having some issues to write on LDAP but 
> is more probably due server stuff and not django-ldapdb itself. Probably 
> django-ldapdb is a good start for a backend, but doesn't have much 
> documentation, mostly examples only.
>
> django-auth-ldap (doc athttp://packages.python.org/django-auth-ldap/, source 
> athttps://bitbucket.org/psagers/django-auth-ldap):testing now, the docs show 
> that it's amazing with all backend and update of users working very well at 
> user login. This kind of functionality is required for me.
>
> Since ldapdb can search, update and add users as I see in code we just need 
> to do some work on lookups and doc, because istartswith as example doesn't 
> works, but it is not much trouble I guess. At other side ldapdb lacks a 
> authentication backend that can update user data at login and is easy to 
> update django tables like auth-ldap does (see documentation). I'll use both 
> for now because my time about it is very small but in future I'm ready to 
> join on efforts to merge both apps and construct a full ldap backend / ldap 
> orm for django.
>
> Felipe 'chronos' Prenholato.
> Linux User nº 405489
> Home page:http://chronosbox.org/blog
> Twitter:http://twitter.com/chronossc
>
> 2011/3/21 David De La Harpe Golden 
>
> On 03/11/10 07:48, sebastien piquemal wrote:
>
> > I have thought of many solutions to replace ldapdb. I came to
> > conclusion than the cleanest, and most useful for the community, would
> > be to implement a real db backend for ldap. However, I have been told
> > that it is an awfully big task !
>
> It would be big...
>
> BTW "pumpkin" is another project that attempts an ORM-like (let's say
> ODM) interface.  It's not django integrated, i.e. it's not a ldap-nonrel
> backend for the Django ORM, it's a separate Somewhat-Django-ORM-like
> ODM.  http://pypi.python.org/pypi/pumpkin/0.1.0
>
> I'd also recommend taking a close look at ldap.schema.models in
> python-ldap source itself - it's "half an ODM" in itself, though it
> can't save and still doesn't really datatype-map (python-ldap is a thin
> layer on top of libldap and returns strings e.g. you get a "FALSE" back
> not a python False. Yeargh), it does introspect the schema and handle
> some horrible little details of attribute lookup for you.
>
> We also grew something of an ODM for in-house use, sitting on top of
> python-ldap, doing a little mapping of datatypes (only just enough for
> our needs), allowing saving.  It's unreleased at time of writing and,
> um, what happens to it later won't be up to me.  Pumpkin is probably
> better anyway.  Our Django ORM integration, such as it is, is by "fake"
> surrogate django models in RDBMS.  So again not a /backend/ for the
> django ORM - Instead we (ab)use entryUUID and syncrepl entryCSN ldap
> operational attributes to keep some almost featureless "LDAPEntry" model
> instances in the RDBMS roughly in-sync via polling*.  This allowed
> signals to fire etc so a django/celery based system can be somewhat
> reactive to directory changes both inside and  outside its control.  But
> our ldap directory is and will remain fairly small (thousands to tens of
> thousands of entries) having an RDBMS row for every entry in ldap works
> out okay, you wouldn't want to do it that way with a giant directory.
>
> (* We toyed with the idea of making a full-blown syncrepl client on top
> of python-ldap for something lighter weight than polling, but that's not
> a small job either.  And there's some support in openldap for having
> /slapd backend to 

Auto refresh of page for one user on other user's update

2011-03-24 Thread ydjango
Two users A & B are both viewing same page and data  from two
different locations via browser.

User A start making changes to data on Page. For user B that piece of
data gets locked (ie he cannot change it till user A is done).

User A finishes making changes. User B's page auto refreshes to
reflect the changes A has done.

Any clue on how to do it? Any django/python based framework that can
help?

( Google docs and some web apps implement this functionality)

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



Re: Is there any Open Source Django Newspaper CMS?

2011-03-24 Thread Rehmetjan Tursun
Thanks Shacker, this is really helped me. this is really what I want to.
Ellington is Commercial, not for free. Armstrong CMS is good and open
source.
but it says it will released at June 2011. and I will wait :)


On Thu, Mar 24, 2011 at 12:32 AM, shacker  wrote:

> Django is used by a lot of newspaper / news sites, but they generally
> use it to build the CMS that fits their exact needs. That's kind of
> the point of using a framework like Django rather than a CMS like
> Drupal - you don't suffer from the "opinions" of the CMS, and instead
> use the tools provided (plus re-usable apps) to build a system that
> fits your org perfectly.
>
> That said, newspapers do have a lot of needs in common, and Ellington
> has been the big commercial Django CMS tuned to that need. But the
> Knight Foundation, who have sponsored innovation and advancement in
> news publication for decades, have just awarded nearly a million
> dollars to the Bay Citizen and the Texas Tribune (two big Django news
> shops) to develop an open source Django-based CMS tuned to news needs:
>
>
> http://www.niemanlab.org/2011/03/wordpress-for-news-orgs-knight-gives-bay-citizen-texas-tribune-975000-for-open-source-cms/
>
> Until that's release, your best bet is to do what all news orgs using
> Django do - use it to build the CMS you need.
>
> Scot
>
> --
> You received this message because you are subscribed to the Google 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.
>
>


-- 
*Rehmetjan Tursun*

-- 
You received this message because you are subscribed to the Google 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 multiple databases router

2011-03-24 Thread Russell Keith-Magee
On Thu, Mar 24, 2011 at 3:15 PM, dy  wrote:
> Hi Jacob:
>
>    Yes, you understand right!Thank you for your reply.
>
> As you said,is this a bug of django1.2.3? Or this feature can be used
> in django-1.2.3, but at a higher version is disabled.
>
> Moreover, in the official documentation(on this page:http://
> docs.djangoproject.com/en/1.3/topics/db/multi-db/), I did not see that
> django does not support the primary foreign keys across databases.As
> you know , sometimes the demand is very strange , so I wonder why I
> can use it on django-1.2.3 and not on django-1.2.5 or higher
> version .This made me very confused.

It was a bug in Django 1.2.3 that it was allowed at all. The
documentation has always said that cross-database foreign keys aren't
allowed [1]. In the process of fixing a different bug (the fix was
included in 1.2.4), the validation rules for foreign keys were
modified; you are now hitting those validation rules.

[1] 
http://docs.djangoproject.com/en/1.2/topics/db/multi-db/#limitations-of-multiple-databases

Yours,
Russ Magee %-)

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



Re: Is there any Open Source Django Newspaper CMS?

2011-03-24 Thread km
try https://www.django-cms.org/
KM

On 3/24/11, Rehmetjan Tursun  wrote:
> Thanks Shacker, this is really helped me. this is really what I want to.
> Ellington is Commercial, not for free. Armstrong CMS is good and open
> source.
> but it says it will released at June 2011. and I will wait :)
>
>
> On Thu, Mar 24, 2011 at 12:32 AM, shacker  wrote:
>
>> Django is used by a lot of newspaper / news sites, but they generally
>> use it to build the CMS that fits their exact needs. That's kind of
>> the point of using a framework like Django rather than a CMS like
>> Drupal - you don't suffer from the "opinions" of the CMS, and instead
>> use the tools provided (plus re-usable apps) to build a system that
>> fits your org perfectly.
>>
>> That said, newspapers do have a lot of needs in common, and Ellington
>> has been the big commercial Django CMS tuned to that need. But the
>> Knight Foundation, who have sponsored innovation and advancement in
>> news publication for decades, have just awarded nearly a million
>> dollars to the Bay Citizen and the Texas Tribune (two big Django news
>> shops) to develop an open source Django-based CMS tuned to news needs:
>>
>>
>> http://www.niemanlab.org/2011/03/wordpress-for-news-orgs-knight-gives-bay-citizen-texas-tribune-975000-for-open-source-cms/
>>
>> Until that's release, your best bet is to do what all news orgs using
>> Django do - use it to build the CMS you need.
>>
>> Scot
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>>
>>
>
>
> --
> *Rehmetjan Tursun*
>
> --
> You received this message because you are subscribed to the Google 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.



Admin theme started reverting to default

2011-03-24 Thread gondor
I don't know if anyone has has this problem.  I have been using the
test django server and it has always rendered my customized admin
panel correctly.  One day out of the blue the admin panel just started
using the default.  I don't think I made any changes.  I understand
this is kind of vague but i'm looking for suggestions on what to look
for and where to look.

None of the template/admin/ admin template modifications are
visible...

(r'^(.*),admin.site.root)

Any suggestions or recommendations are very welcome.

-- 
You received this message because you are subscribed to the Google 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 multiple databases router

2011-03-24 Thread dy
On 3月24日, 下午3时53分, Russell Keith-Magee 
wrote:
> On Thu, Mar 24, 2011 at 3:15 PM, dy  wrote:
> > Hi Jacob:
>
> >Yes, you understand right!Thank you for your reply.
>
> > As you said,is this a bug of django1.2.3? Or this feature can be used
> > in django-1.2.3, but at a higher version is disabled.
>
> > Moreover, in the official documentation(on this page:http://
> > docs.djangoproject.com/en/1.3/topics/db/multi-db/), I did not see that
> > django does not support the primary foreign keys across databases.As
> > you know , sometimes the demand is very strange , so I wonder why I
> > can use it on django-1.2.3 and not on django-1.2.5 or higher
> > version .This made me very confused.
>
> It was a bug in Django 1.2.3 that it was allowed at all. The
> documentation has always said that cross-database foreign keys aren't
> allowed [1]. In the process of fixing a different bug (the fix was
> included in 1.2.4), the validation rules for foreign keys were
> modified; you are now hitting those validation rules.
>
> [1]http://docs.djangoproject.com/en/1.2/topics/db/multi-db/#limitations-...
>
> Yours,
> Russ Magee %-)


Hi Russ Magee,

Thank you very much.

I want to know if I continue to use it like this what problems will
happen.If you or someone else have this experience,can you tell me?

Thanks again.

Dy

-- 
You received this message because you are subscribed to the Google 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: About using Django Auth with my app, Auto saving the User

2011-03-24 Thread Amanjeev Sethi
Thanks a lot.

-- 
You received this message because you are subscribed to the Google 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 & Two Factor Authentication (2FA)

2011-03-24 Thread Sam Lai
On 24 March 2011 07:52, pokecho  wrote:
> I am writing to ask whether it is possible to configure
> "django.contrib.auth"  so that it can implement Two Factor
> Authentication to step up login security.
>
> The idea is that instead authenticating against just "username" and
> "password" one could add another field say "passcode" which would
> receive a dynamic token or PIN for additional security.

Is a separate passcode field really necessary? Of all the 2FA auth
systems I've used, most ask the user to concatenate their
user-selected PIN and the generated code together to form the
password.

The only exception that I've encountered is 2FA Windows
authentication, and that was because the login screen still needed to
pass the user's Windows credentials on to the Windows logon process so
it could authenticate the user itself using the username and password
before logging them in. The extra password doesn't add much security;
it is only there to placate Windows requirements.

If you can repurpose the password field to be a PIN + token value
field, then a custom auth backend would be simple and all that's
required.

> I have tried to extend "User" by subclassing, while noting that there
> a couple of objections to this approach. I'm not a fan of monkey-
> patching and I am not quite sure adding fields using the documented
> 'ForeignKey' extension strategy will do the trick. In any case, when I
> try to login as admin after all the grunt work of subclassing, Python
> spits out all sorts of exceptions including the nefarious *None Type*
> --  'None Type' object has no attribute 'DoesNotExist'.
>
> Finally, assuming we can effectively implement 2 Factor
> Authentication, how would we ensure that the admin adapts to 2FA i.e.
> that its login form contains an additional "passcode" field for user
> token/PIN input and verification.
>
> I am new to Django, but not to Python so any assistance in this matter
> will be highly appreciated. Hacking this is like trying to resolve a
> rubix cube with one hand. So help me out here if you can.
>
> Patrick
>
> --
> You received this message because you are subscribed to the Google 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: Auto refresh of page for one user on other user's update

2011-03-24 Thread Eugene MechanisM
look at http://ape-project.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.



Should I use Python 2.6 with Django 1.3?

2011-03-24 Thread Andre Lopes
Hi,

I'm new to Django. In my system I have Python 2.6 and Python 2.7
installed, but due to some inconsistencies in Python Path I will
uninstall the Python versions and install again.

What I need to know is if Python 2.6 will work without problems with Django 1.3

Best Regards,

-- 
You received this message because you are subscribed to the Google 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: Should I use Python 2.6 with Django 1.3?

2011-03-24 Thread Russell Keith-Magee
On Thu, Mar 24, 2011 at 6:50 PM, Andre Lopes  wrote:
> Hi,
>
> I'm new to Django. In my system I have Python 2.6 and Python 2.7
> installed, but due to some inconsistencies in Python Path I will
> uninstall the Python versions and install again.
>
> What I need to know is if Python 2.6 will work without problems with Django 
> 1.3

Yes, it will.

http://docs.djangoproject.com/en/1.3/faq/install/#what-are-django-s-prerequisites

Yours,
Russ Magee %-)

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



Re: form.is_valid() changes a ModelForm's associated instance now?

2011-03-24 Thread Vermus
>     item = Item.objects.get(id=1)
>     print 'item.value: %s' % item.value
>     form = ItemModelForm(request.POST, instance=item)
>     # NOTE: This fixes the problem:
>     old_item = copy.deepcopy(item)
>     if form.is_valid():
>         print 'old_item.value: %s' % old_item.value
>         print "form.cleaned_data['value']: %s" %
> form.cleaned_data['value']
>         new_item = form.save(commit=False)
>         print 'new_item.value: %s' % new_item.value

What about many-to-many fields?

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



Re: Django 1.3 URL resolvers is not working

2011-03-24 Thread Navaneethan
I am using django version 1.2.5 Here could you please point this glitch

NavaTux  gmail.com> writes:

>
> Here just i am authenticating a user in django and logout him
>
> authentication view is working fine and i wriiten a log out view which
> is here
>
> def view_logout(request):
> from django.contrib.auth import logout as django_logout
> django_logout(request)
> return HttpResponseRedirect(urlresolvers.reverse('login'))
>
> this is my template content which is given the link to logout
>
>" Logout "
>
> when rendering this application , it asks username and password ,
> after given both, home page is being displayed then clicking Logout
> url
> it displays the below error
>
> Traceback::
>
> ""Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/logout/
>
> Django Version: 1.3
> Python Version: 2.6.5
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'options_alpha']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.middleware.csrf.CsrfResponseMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
> Traceback:
> File "/home/hirelex/workspace/optionsalpha/lib/python2.6/site-packages/
> django/core/handlers/base.py" in get_response
>   111. response = callback(request,
> *callback_args, **callback_kwargs)
>
> Exception Type: TypeError at /logout/
> Exception Value: 'str' object is not callable""
>
> I am using latest django 1.3 and i did editing the middleware classes
> to avoid the error "CSRF token verification failed" by following this
> link  verification-failed/>.then it works fine
>
> The logout function makes the problem
>
> hope you will point this error
>
> if you need any information i ll give
>



-- 
---
regards,

NavaTux 

It blogs @ http://navaspot.wordpress.com

http://twitter.com/NavaTux

-- 
You received this message because you are subscribed to the Google 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 multiple databases router

2011-03-24 Thread Ramiro Morales
2011/3/24 dy :
>
> I want to know if I continue to use it like this what problems will
> happen.If you or someone else have this experience,can you tell me?

Being an unsupported setup, I'd say you are in unexplored territory here
so you will need to find the potential shortcomings by yourself.

One possibility would be to create a test suite that covers all your use
cases of cross-DB relationships.

-- 
Ramiro Morales

-- 
You received this message because you are subscribed to the Google 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 & Two Factor Authentication (2FA)

2011-03-24 Thread pokecho
Hi Sam,

Thanks for the note. All the 2FA systems I have used have single field
for both the password and the token.

>Is a separate passcode field really necessary?

However, from a usability standpoint I believe decoupling the two
would make it easier for the user to recognize that the token/PIN is
fed to and consumed by the system through a different field. So I am
thinking about balancing usability and security. If the token and
password live in the same field, we increase the margin of error for a
non-techie user who must enter a known value(the password) and a
dynamic (possibly all numeric) value (i.e. the token).

>The extra password doesn't add much security; it is only there to placate 
>Windows requirements.

Aside from Man-In-the-middle attacks and Trojan raider, which present
challenges for all authentication protocols, the security is
heightened because the second value is dynamic and expires after a
specified time.

So how do I configure contrib.auth to authenticate against three input
values "username"(static), password(static/encrypted) and PIN/
token(dynamic/encrypted)? That is the question.

Patrick

On Mar 24, 5:04 am, Sam Lai  wrote:
> On 24 March 2011 07:52, pokecho  wrote:
>
> > I am writing to ask whether it is possible to configure
> > "django.contrib.auth"  so that it can implement Two Factor
> > Authentication to step up login security.
>
> > The idea is that instead authenticating against just "username" and
> > "password" one could add another field say "passcode" which would
> > receive a dynamic token or PIN for additional security.
>
> Is a separate passcode field really necessary? Of all the 2FA auth
> systems I've used, most ask the user to concatenate their
> user-selected PIN and the generated code together to form the
> password.
>
> The only exception that I've encountered is 2FA Windows
> authentication, and that was because the login screen still needed to
> pass the user's Windows credentials on to the Windows logon process so
> it could authenticate the user itself using the username and password
> before logging them in. The extra password doesn't add much security;
> it is only there to placate Windows requirements.
>
> If you can repurpose the password field to be a PIN + token value
> field, then a custom auth backend would be simple and all that's
> required.
>
>
>
>
>
>
>
> > I have tried to extend "User" by subclassing, while noting that there
> > a couple of objections to this approach. I'm not a fan of monkey-
> > patching and I am not quite sure adding fields using the documented
> > 'ForeignKey' extension strategy will do the trick. In any case, when I
> > try to login as admin after all the grunt work of subclassing, Python
> > spits out all sorts of exceptions including the nefarious *None Type*
> > --  'None Type' object has no attribute 'DoesNotExist'.
>
> > Finally, assuming we can effectively implement 2 Factor
> > Authentication, how would we ensure that the admin adapts to 2FA i.e.
> > that its login form contains an additional "passcode" field for user
> > token/PIN input and verification.
>
> > I am new to Django, but not to Python so any assistance in this matter
> > will be highly appreciated. Hacking this is like trying to resolve a
> > rubix cube with one hand. So help me out here if you can.
>
> > Patrick
>
> > --
> > You received this message because you are subscribed to the Google 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 
> > athttp://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: Custom admin action problem

2011-03-24 Thread Jônatas Vieira
Nobody?


On 23 mar, 19:20, Jônatas Vieira  wrote:
> Hi there.
>
> I'm having a weird issue with a custom admin action. It works pretty
> fine locally, but on the live server what happens is:
>
> * it renders to the template - OK
> * after submit, the function is executed (the changes and everything
> are applied using the post data, collected from the template) - OK
> * then, on debug = True mode, it crashes with a "page not found"
> error; after then, I either need to clear all my cookies or, in most
> of times, need to restart the browser, otherwise the whole site is
> unaccessible to me, with the same "page not found" error, always
> listing my urls from the main urls.py.
>
> I want to make clear that it redirects, after post, to the very same
> url it was before, all urls are valid (remember it works PERFECTLY on
> my local server), but no one seems to work after the issue, only after
> I restart my browser and clear my data.
>
> Here goes, as example, the admin.py code I'm using:
>
> class SectorAdmin(admin.ModelAdmin):
>     actions = ['apply_index']
>
>     def apply_index(self, request, queryset):
>         form = None
>
>         if 'apply' in request.POST:
>             form = ApplyIndexForm(request.POST)
>
>             if form.is_valid():
>                 index = form.cleaned_data['index']
>
>                 sector_names = []
>                 for sector in queryset:
>                     sector.index_change(index)
>                     sector_names.append(sector.name)
>
>                 self.message_user(request, "Index of %s%% successfully
> applied to %s." % (index, ', '.join(sector_names)))
>                 return HttpResponseRedirect(request.get_full_path())
>
>         if not form:
>             form = ApplyIndexForm(initial={'_selected_action':
> request.POST.getlist(admin.ACTION_CHECKBOX_NAME)})
>
>         VARS = {
>             'sectors': queryset,
>             'apply_form': form,
>         }
>
>         return render_to_response('admin/heritage/sector/
> apply_index.html', VARS, context_instance=RequestContext(request))
>     apply_index.short_description = "Apply new sector index"
>
> admin.site.register(Sector, SectorAdmin)
>
> Does anybody know what this could be?

-- 
You received this message because you are subscribed to the Google 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: Should I use Python 2.6 with Django 1.3?

2011-03-24 Thread NickH


On Mar 24, 6:50 am, Andre Lopes  wrote:
> Hi,
>
> I'm new to Django. In my system I have Python 2.6 and Python 2.7
> installed, but due to some inconsistencies in Python Path I will
> uninstall the Python versions and install again.
>
> What I need to know is if Python 2.6 will work without problems with Django 
> 1.3
>
> Best Regards,


Django 1.3 should work just fine on python 2.6. Django is compatible
with python 2.4+, but not 3.x yet.
http://pypi.python.org/pypi/Django/1.3

-Nick




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



Re: Is there any Open Source Django Newspaper CMS?

2011-03-24 Thread NickH


On Mar 23, 9:09 am, Kenneth Gonsalves  wrote:
> On Wed, 2011-03-23 at 03:57 -0700, Rehmetjan wrote:
> > Hello all, I am new to django.
> > I am heard about Django is comes from a Newspaper group, but never
> > found a
> > Newspaper CMS. (Not meant Django-CMS)
> > PHP has many Newspaper CMS like Joomla! and Drupal. If anyone tell me
> > where
> > can I find Open source CMS for Newspaper written in Django?
>
> django itself?
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/


There are a number of CMS options for django.

You can find a nice comparison here:
http://djangopackages.com/grids/g/cms/

I've used Mezzanine and it's very good, but might not be the best for
a large newspaper site.

It all depends on your needs, so I'd probably try out a couple of the
CMS's on that list to figure which you like best and then customize it
from there to fit your needs.

-Nick

-- 
You received this message because you are subscribed to the Google 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: High availability deployments

2011-03-24 Thread Kristaps Kūlis
 See this blog post: 
http://rambleon.usebox.net/post/3279121000/how-to-gracefully-restart-django-running-fastcgi
 TL;DR : just send SIGHUP to flup process (pidfile option to fastcgi),
like this:
 kill -SIGHUP `cat /path/to/flup.pid`
 I suggest using Gunicorn, as it handles graceful reloads better than
flup in my experience (trought newest editions of flup handle graceful
reloads with SIGUSR).
 Also: graceful reload is impossible when you are running database
schema changes as that is not atomic process. Put some nice 502 error
page like: where are updating teh codez, drink coffeee!
On Mar 24, 8:56 am, Jani Tiainen  wrote:
> Hi,
>
> First at all, if you're working with real high availability system you already
> have resolved most of the single point of failure problems, and other non-
> django related issues (like broken hardware, broken network connections etc.)
>
> And by looking what you're experiencing now indicates that you haven't done
> not your homework about real high availability systems.
>
> And finally about Django:
>
> Django itself by design uses share nothing architecture, so if you don't
> deliberately program something that is shared it won't cause any side-effects.
>
> When run behind webservers you must shut down all instances gracefully (let
> them complete last request before closing them down) to avoid loss of data.
>
> On Thursday 24 March 2011 08:29:00 Shamail Tayyab wrote:
>
> > Hi,
>
> >    We have a setup in which we can't afford downtime (even while
> > deployment).
>
> > Our setup is based on lighttpd + django (on fcgi via flup). What my
> > problem is, when we restart django, the site goes down for about a
> > couple of seconds (and all API calls to DB remains incomplete
> > resulting in 500.html being rendered for users).
>
> > We need a setup in which we can restart our system in a safe way.
>
> > As an initial thought, instead of 1 site instance, lets have 2, then
> > use lighty's load balancing to have both the instances run, then drop
> > the previous instance.
>
> > Is this feasible? Will it lead to inconsistencies? How can I still
> > ensure that calls on previous instance completely stops before
> > dropping it?
>
> > Any other way to do this?
>
> > Tx

-- 
You received this message because you are subscribed to the Google 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: High availability deployments

2011-03-24 Thread Kristaps Kūlis
Hello,
 First of all, problem is not with lighttpd, but with flup

On Mar 24, 8:29 am, Shamail Tayyab  wrote:
> Hi,
>
>    We have a setup in which we can't afford downtime (even while
> deployment).
>
> Our setup is based on lighttpd + django (on fcgi via flup). What my
> problem is, when we restart django, the site goes down for about a
> couple of seconds (and all API calls to DB remains incomplete
> resulting in 500.html being rendered for users).
>
> We need a setup in which we can restart our system in a safe way.
>
> As an initial thought, instead of 1 site instance, lets have 2, then
> use lighty's load balancing to have both the instances run, then drop
> the previous instance.
>
> Is this feasible? Will it lead to inconsistencies? How can I still
> ensure that calls on previous instance completely stops before
> dropping it?
>
> Any other way to do this?
>
> Tx

-- 
You received this message because you are subscribed to the Google 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.



decorators and generic views

2011-03-24 Thread Ian Stokes-Rees
I think with the move to class-based Generic Views it is necessary to update 
this documentation:

Limiting access to generic views 

To limit access to a *generic 
view*, 
write a thin wrapper around the view, and point your URLconf to your wrapper 
instead of the generic view itself. For example:

from django.views.generic.date_based import object_detail
@login_requireddef limited_object_detail(*args, **kwargs):
return object_detail(*args, **kwargs)

I am trying to put an @login_required decorator around ListView.as_view(...) 
but not having any luck.  Advice on how properly map from urls.py to a 
function in the wrapped view would be appreciated.  My current best attempt 
is below

Cheers,

Ian

urls.py BEFORE:

from gridportal.wsmr.models import WSMRTask
from gridportal.wsmr.views  import list, create, view, edit, 
copy, delete, reset

urlpatterns = patterns('',
(r'tasks/?$' , ListView.as_view(model=WSMRTask)), # 
working, but no access control

urls.py AFTER:

from gridportal.wsmr.models import WSMRTask
from gridportal.wsmr.views  import list, create, view, edit, 
copy, delete, reset

urlpatterns = patterns('',
(r'tasks/?$' , list()), # not working

views.py AFTER:

@login_required()
def list(*args, **kwargs):
return ListView.as_view(model=WSMRTask)

I get the exception:

_wrapped_view() takes at least 1 argument (0 given)


-- 
You received this message because you are subscribed to the Google 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: Turning off USE_L10N more than doubled my site performance!

2011-03-24 Thread Carsten Fuchs

Dear Russell,

thank you very much for your reply!

Am 24.03.2011 01:04, schrieb Russell Keith-Magee:

Can you share your profiling data?


Sure, gladly:

with USE_L10N = True, ordered by internal time:
http://pastebin.com/fkyF5nLw

with USE_L10N = True, ordered by cumulated time, with callees:
http://pastebin.com/GXSsV3qk


with USE_L10N = False, ordered by internal time:
http://pastebin.com/JCu3ePEu

with USE_L10N = False, ordered by cumulated time, with callees:
http://pastebin.com/3bYjsk82


[ Today I measured a difference in performance of only factor 13.832 / 
8.549 == ca. 1.6  vs. better than 2.0 yesterday, but that is probably 
related to my setting DEBUG = False for all of the above vs. DEBUG = 
True yesterday (which of course was, in the light of performance 
profiling, a stupid  oversight). ]



I'd be very happy to learn what you make of this data (afaics, the 
problem could perfectly well be in my app code, not in Django).

:-)

Best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Auto refresh of page for one user on other user's update

2011-03-24 Thread Shawn Milochik
In addition there's hookbox.org.

There was a great talk on it at PyCon.
http://pycon.blip.tv/file/4883145/

In addition, I'm in the process of playing with Hookbox, after which
I'll write a blog post detailing how to use it with Django.

In the meantime, this is the tutorial I've found most helpful for
Hookbox. It's using Flask instead of Django, but if you've used Django
you'll find Flask extremely simple to play with.
http://charlesleifer.com/blog/writing-a-real-time-chat-app-using-hookbox-and-flask/

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.



How to install psycopg2 using Pip?

2011-03-24 Thread Andre Lopes
Hi,

This question is not directly related with Django, but with Python.

I have installed "virtualenv" to have a virtual environment. Now I
need to instal "psycopg2" in my virtual environment, but I have not
successfully installed.

My steps:

[quote]
pip install
http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
[/quote]

And I got this message with an error:

[quote]
Downloading/unpacking
http://pypi.python.org/packages/source/p/psycopg2/psycopg2
-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
  Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded
  Running setup.py egg_info for package from
http://pypi.python.org/packages/sou
rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

python setup.py build_ext --pg-config 
/path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info

creating pip-egg-info\psycopg2.egg-info

writing pip-egg-info\psycopg2.egg-info\PKG-INFO

writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt

writing dependency_links to 
pip-egg-info\psycopg2.egg-info\dependency_links.txt

writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'

warning: manifest_maker: standard file '-c' not found

Error: pg_config executable not found.



Please add the directory containing pg_config to the PATH

or specify the full executable path with the option:



python setup.py build_ext --pg-config /path/to/pg_config build 
...



or with the pg_config option in 'setup.cfg'.


Command python setup.py egg_info failed with error code 1
Storing complete log in C:\Documents and Settings\anlopes\Application
Data\pip\p
ip.log
[/quote]

My question:

How can I tell to "pip" where is my pg_config?

Best Regards,

-- 
You received this message because you are subscribed to the Google 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.



Rewriting Java UI for Django?

2011-03-24 Thread David Kovar
Greetings,

I'm fairly experienced with Python for backend, non UI/UX tasks but am very new 
to trying to do any UI work other than command lines. This'll come off as a 
very newbie question, and it is.

I need to take an existing Java/Swing UI and wrap it inside of Django to 
provide authentication, customer support, etc. I've got a pretty good handle on 
most of this, except for:

What is the best Python approach to writing a web UI that includes 
dropdown menus, radio buttons, etc?

It may be that Django will do this for me, but I've not figured out how to do 
so yet.

Thanks

-David

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



Re: Auto refresh of page for one user on other user's update

2011-03-24 Thread Marwan Al-Sabbagh
I'm working on an application that has a similar requirement. If you can
wait for a few weeks, I'll probably have it ready and released sometime next
month. I'll be releasing it as an open source project specifically to work
with django. If it's something you're interested in shoot me an email and
I'll make sure to keep you posted once I release it.

cheers,
Marwan

On Thu, Mar 24, 2011 at 5:57 PM, Shawn Milochik  wrote:

> In addition there's hookbox.org.
>
> There was a great talk on it at PyCon.
> http://pycon.blip.tv/file/4883145/
>
> In addition, I'm in the process of playing with Hookbox, after which
> I'll write a blog post detailing how to use it with Django.
>
> In the meantime, this is the tutorial I've found most helpful for
> Hookbox. It's using Flask instead of Django, but if you've used Django
> you'll find Flask extremely simple to play with.
>
> http://charlesleifer.com/blog/writing-a-real-time-chat-app-using-hookbox-and-flask/
>
> 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.
>
>

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



Re: How to install psycopg2 using Pip?

2011-03-24 Thread Shawn Milochik
Ensure that pg_config is on your PATH and it should 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: ANN: Django 1.3 released

2011-03-24 Thread Aryeh Leib Taurog
On Mar 23, 8:15 am, James Bennett  wrote:
> Django 1.3 has been officially released.

I have created a windows compiled html "help" file of the django 1.3
documentation.
It is available at http://www.aryehleib.com/CHM.html

I've also made available there chm files for earlier django releases
and for a snapshot from svn trunk which I try to keep relatively
current.

-- 
You received this message because you are subscribed to the Google 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: Failed to build documentation (solved)

2011-03-24 Thread Lic . José M . Rodriguez Bacallao
hey, I am using ubuntu 10.10, do I really need to update Sphinx to
build documentation?

On Thu, Mar 10, 2011 at 3:51 AM, Thomas Guettler  wrote:
> Hi,
>
> the problem is solved, this is just for other people who have the same error.
>
> When you try to build the documentation and get the following error:
>
>
>  File "/home/user/_django-trunk/docs/_ext/djangodocs.py", line 86, in run
>    xrefs = roles.XRefRole()('doc', linktext, linktext, self.lineno, 
> self.state)
> AttributeError: 'module' object has no attribute 'XRefRole'
>
> You might be running an old version of Sphinx. Version 0.6 is not supported.
>
> You need to use the "-U" Option (update), to get the latest version:
>
> Example: easy_install -U --prefix=$HOME Sphinx
>
> Without -U easy_install copied the old version from /usr/lib into my home
> directory.
>
>  HTH,
>    Thomas Güttler
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
>
> --
> You received this message because you are subscribed to the Google 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.
>
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

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



Re: How to install psycopg2 using Pip?

2011-03-24 Thread Jacob Kaplan-Moss
Hi Andre --

This indicates that you don't have the development packages for
PostgreSQL. psycopg2 is written mostly in C, and needs to be compiled
and linked against PostgreSQL. It does this by running a command
called pg_config, which is part of the PostgreSQL dev package.

You haven't indicated which platform you're on, so I can't tell you
exactly how to install the dev packages. On Ubuntu, it'd be "apt-get
install libpq-dev", for example.

Since this isn't really Django-related, you might want to also take a
look at the psycopg2 docs, especially the parts about building
problems: 
http://www.initd.org/psycopg/docs/faq.html#problems-compiling-and-deploying-psycopg2.

Good luck,

Jacob

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



Re: Custom admin interface

2011-03-24 Thread Jacob Kaplan-Moss
Hi Tsolmon --

You can find documentation on Django's admin interface at
http://docs.djangoproject.com/en/1.3/ref/contrib/admin/. It should
tell you enough to get started.

Jacob

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



Re: How to install psycopg2 using Pip?

2011-03-24 Thread Shawn Milochik
This actually has nothing to do with Python -- I'm talking about your
PATH, not your PYTHONPATH.

Short version: Type 'which pg_config' at the command line. If it is
found, then it's on your PATH. Otherwise, it's not, which appears to
be the case.

If you want to just do a temporary fix, you can follow these steps:

Run this:
find / -name pg_config 2>>/dev/null

#let's assume the result of the previous command is this:
/usr/lib/postgresql/8.4/bin/pg_config

Add that path to your PATH temporarily

export PATH=$PATH:/usr/lib/postgresql/8.4/bin

You should then be able to do the pip install.

If that doesn't work because pg_config isn't found on your system at
all then see Jacob's suggestions.

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: How to install psycopg2 using Pip?

2011-03-24 Thread Andre Lopes
Thanks for the reply.

How can I do that? I'm new to Python, I'm not aware of what is Python
path.

Best Regards,


On Mar 24, 3:10 pm, Shawn Milochik  wrote:
> Ensure that pg_config is on your PATH and it should 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: How to install psycopg2 using Pip?

2011-03-24 Thread Andre Lopes
I have solved.

I just edited "setup.cfg" on the psycopg2 and added:

pg_config=C:\Program Files\PostgreSQL\8.4\bin\pg_config.exe

Thanks for the help.

Best Regards,



On Mar 24, 3:49 pm, Shawn Milochik  wrote:
> This actually has nothing to do with Python -- I'm talking about your
> PATH, not your PYTHONPATH.
>
> Short version: Type 'which pg_config' at the command line. If it is
> found, then it's on your PATH. Otherwise, it's not, which appears to
> be the case.
>
> If you want to just do a temporary fix, you can follow these steps:
>
>     Run this:
>     find / -name pg_config 2>>/dev/null
>
>     #let's assume the result of the previous command is this:
> /usr/lib/postgresql/8.4/bin/pg_config
>
>     Add that path to your PATH temporarily
>
>     export PATH=$PATH:/usr/lib/postgresql/8.4/bin
>
> You should then be able to do the pip install.
>
> If that doesn't work because pg_config isn't found on your system at
> all then see Jacob's suggestions.
>
> 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: High availability deployments

2011-03-24 Thread Cal Leeming [Simplicity Media Ltd]
You need to handle this within your code logic.

The problem is, when a 500 Error is given back, you don't know what actually
happened on the server side. For all you know, it could have been half way
through its task.

You need to add logic within the client side and server side code, to handle
any events like this.

On Thu, Mar 24, 2011 at 6:29 AM, Shamail Tayyab  wrote:

> Hi,
>
>   We have a setup in which we can't afford downtime (even while
> deployment).
>
> Our setup is based on lighttpd + django (on fcgi via flup). What my
> problem is, when we restart django, the site goes down for about a
> couple of seconds (and all API calls to DB remains incomplete
> resulting in 500.html being rendered for users).
>
> We need a setup in which we can restart our system in a safe way.
>
> As an initial thought, instead of 1 site instance, lets have 2, then
> use lighty's load balancing to have both the instances run, then drop
> the previous instance.
>
> Is this feasible? Will it lead to inconsistencies? How can I still
> ensure that calls on previous instance completely stops before
> dropping it?
>
> Any other way to do this?
>
>
> Tx
>
> --
> You received this message because you are subscribed to the Google 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: How to install psycopg2 using Pip?

2011-03-24 Thread Shawn Milochik
On Thu, Mar 24, 2011 at 12:03 PM, Andre Lopes  wrote:
> I have solved.
>
> I just edited "setup.cfg" on the psycopg2 and added:
>
> pg_config=C:\Program Files\PostgreSQL\8.4\bin\pg_config.exe


Yeah, that's the easiest method, but you specifically wanted to know
how to install it with pip. That way you have to install the module
manually. But it works. ;o)

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: Rewriting Java UI for Django?

2011-03-24 Thread Patrick McDonnell
David - I'm not sure I follow exactly what you're asking.

If you're trying to basically port a Java/Swing application to Django:
Django is a web application framework.  Python with the Django libraries are
used on the back end, and HTML is used on the front end (technically it is
possible to use something other than an HTML front end, but that woud be
very unusual).  So, in answer to your question, HTML/JavaScript/CSS/etc are
used to develop your UI.  Django does offer some utilities to make your job
easier (see the docs for forms and templates), but the majority of the UI
design must be done by hand.

Also note that Django does automatically generate an admin UI for all of
your database models.  By default, its a pretty simple CRUD interface, but
you can modify it a bit, see the docs.

If, however, you're asking how to "wrap" an existing Java/Swing application
inside of Django... That would be much more complicated, and probably not a
very good idea.

HTH


On Thu, Mar 24, 2011 at 10:13 AM, David Kovar  wrote:

> Greetings,
>
> I'm fairly experienced with Python for backend, non UI/UX tasks but am very
> new to trying to do any UI work other than command lines. This'll come off
> as a very newbie question, and it is.
>
> I need to take an existing Java/Swing UI and wrap it inside of Django to
> provide authentication, customer support, etc. I've got a pretty good handle
> on most of this, except for:
>
>What is the best Python approach to writing a web UI that includes
> dropdown menus, radio buttons, etc?
>
> It may be that Django will do this for me, but I've not figured out how to
> do so yet.
>
> Thanks
>
> -David
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google 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.



contenttypes installed but not ???

2011-03-24 Thread Jon Walsh
If anyone could make sense of the below traceback, I'd greatly
appreciate it!

Noting that contenttypes is installed (as seen below) but Django says
it isn't (as seen below).

thanks in advance!
Jon

===

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8001/
Django Version: 1.2.5
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.webdesign',
 'website.core',
 'website.main']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/core/handlers/base.py" in get_response
  91. request.path_info)
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/core/urlresolvers.py" in resolve
  215. for pattern in self.url_patterns:
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/core/urlresolvers.py" in _get_url_patterns
  244. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/core/urlresolvers.py" in _get_urlconf_module
  239. self._urlconf_module =
import_module(self.urlconf_name)
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/utils/importlib.py" in import_module
  35. __import__(name)
File "/home/jon/files/business/clients/mm/source/website/urls.py" in

  14. (r'^admin/', include(admin.site.urls)),
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/contrib/admin/sites.py" in urls
  243. return self.get_urls(), self.app_name, self.name
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/contrib/admin/sites.py" in get_urls
  203. self.check_dependencies()
File "/custom/virtualenv/music-mission.org.dev/lib/python2.6/site-
packages/django/contrib/admin/sites.py" in check_dependencies
  157. raise ImproperlyConfigured("Put
'django.contrib.contenttypes' in "

Exception Type: ImproperlyConfigured at /
Exception Value: Put 'django.contrib.contenttypes' in your
INSTALLED_APPS setting in order to use the admin application.

-- 
You received this message because you are subscribed to the Google 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: Rewriting Java UI for Django?

2011-03-24 Thread David Kovar
Patrick,

Thank you for the insight. Thankfully, I'm trying to port rather than wrap so 
while I've got a learning curve ahead of me, it isn't a horrible one.

-David

On Mar 24, 2011, at 11:40 AM, Patrick McDonnell wrote:

> David - I'm not sure I follow exactly what you're asking.
>  
> If you're trying to basically port a Java/Swing application to Django: Django 
> is a web application framework.  Python with the Django libraries are used on 
> the back end, and HTML is used on the front end (technically it is possible 
> to use something other than an HTML front end, but that woud be very 
> unusual).  So, in answer to your question, HTML/JavaScript/CSS/etc are used 
> to develop your UI.  Django does offer some utilities to make your job easier 
> (see the docs for forms and templates), but the majority of the UI design 
> must be done by hand.
>  
> Also note that Django does automatically generate an admin UI for all of your 
> database models.  By default, its a pretty simple CRUD interface, but you can 
> modify it a bit, see the docs.
>  
> If, however, you're asking how to "wrap" an existing Java/Swing application 
> inside of Django... That would be much more complicated, and probably not a 
> very good idea.
>  
> HTH
> 
>  
> On Thu, Mar 24, 2011 at 10:13 AM, David Kovar  wrote:
> Greetings,
> 
> I'm fairly experienced with Python for backend, non UI/UX tasks but am very 
> new to trying to do any UI work other than command lines. This'll come off as 
> a very newbie question, and it is.
> 
> I need to take an existing Java/Swing UI and wrap it inside of Django to 
> provide authentication, customer support, etc. I've got a pretty good handle 
> on most of this, except for:
> 
>What is the best Python approach to writing a web UI that includes 
> dropdown menus, radio buttons, etc?
> 
> It may be that Django will do this for me, but I've not figured out how to do 
> so yet.
> 
> Thanks
> 
> -David
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google 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: Admin theme started reverting to default

2011-03-24 Thread Artem
I had something similar with several test projects running on my
machine.
The problem was - auto-generated .pyc files in django sources.. one
project user precompiled\precached files from another..
I guess I mistakenly ran dev-servers with root account, so python
could put .pyc files into that folder...
I made a simple script to remove all pyc files from sources

On 24 мар, 10:27, gondor  wrote:
> I don't know if anyone has has this problem.  I have been using the
> test django server and it has always rendered my customized admin
> panel correctly.  One day out of the blue the admin panel just started
> using the default.  I don't think I made any changes.  I understand
> this is kind of vague but i'm looking for suggestions on what to look
> for and where to look.
>
> None of the template/admin/ admin template modifications are
> visible...
>
> (r'^(.*),admin.site.root)
>
> Any suggestions or recommendations are very welcome.

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



Override table name(s) in application deployment

2011-03-24 Thread Flo Ledermann
Hi all,

I was quite surprised that I couldn't find a way to override table
names for an application's models on a per-deployment basis (i.e. in
settings.py or some other project/site specific file instead of
modifying the models.py file of the app itself)

Although I admit all of these are rare, I think the scenarios of (a)
having table_name naming conflicts between apps or (b) working with
legacy data in existing tables or (c) renaming an app while wanting to
keep the data, would justify the "external" specification of an
application's table names.

In my case I had to rename an application for external reasons, and
would like to continue using the existing data in all my deployments.
Renaming all the tables in the databases would be quite tedious.

The only related thing I could find is http://code.djangoproject.com/ticket/891
which wouldn't help in above scenarios anyway.

What do you think? Is there something I've overlooked?

Best,

Flo

-- 
You received this message because you are subscribed to the Google 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: High-level template and template tag organization

2011-03-24 Thread Artem
something like?
{% if request.user.is_staff %}
  {% include 'smth.html' %}
{% else %}
 {% include 'smth2.html' %}
{% endif %}

On 24 мар, 00:23, Mazery Smith  wrote:
> Hello,
> I have a results.html page and mylibrary.html page on my site that
> both display search information in a results box (broken into two
> columns (a left and a right column)).
>
> The left-handed column stays the same (in terms of data being
> displayed) between both the results page and the mylibrary page.
>
> The right-handed column differs between the two pages depending on the
> user's permissions and status of page objects being displayed.
>
> I started breaking both pages down into a number of templates and I'm
> finding this to be a nightmare b/c I want my view function to pass my
> search results (page objects) to a .html parent of the columns instead
> of to the farthest child downstream. Now I'm thinking about using
> inclusion template tags to make this transition easier.
>
> I'm looking for advice on ways to structure nested templates with
> changing elements based on user permissions and authentification?
>
> Ideas?
>
> Thanks
> Mazery

-- 
You received this message because you are subscribed to the Google 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: Override table name(s) in application deployment

2011-03-24 Thread Jacob Kaplan-Moss
On Thu, Mar 24, 2011 at 12:30 PM, Flo Ledermann
 wrote:
> I was quite surprised that I couldn't find a way to override table
> names for an application's models on a per-deployment basis (i.e. in
> settings.py or some other project/site specific file instead of
> modifying the models.py file of the app itself)

Yup, I've missed this feature quite a few times myself. I'd love to
see a good solution. Of course, it's a bit like If You Give a Mouse a
Cookie here: once you start customizing table names on a
per-deployment basis now you're going to want to customize column
names. And once you do that you'll want to customize indexes. And
then...

But yes, I'd be thrilled to see a proposal here. Double bonus points
if it doesn't introduce a new setting :) Perhaps this might become a
feature of the DB router?

Jacob

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



Generic Foreign Keys in fixtures

2011-03-24 Thread LurkingFrog
Currently, I am writing unit tests for an application that uses
generic foreign keys.  Since the contenttypes are regenerated every
test, I was wondering the most effective way to reconcile the existing
test data with the new contenttypes PKs.

My current thinking is to make an explicit fixture the dumpdata from
contenttypes at the same time I generate the other fixtures I plan to
use in my tests.  From there, I will add code to manually update the
content types in the database to the ones in the aforementioned
contenttypes fixture and call it from the __init__.py in each
application/tests folder.  Since that __init__.py should be called
after the migrations are completed, this should make all the data line
up.

My question is whether this is the most efficient / effective way to
solve this issue.

Thanks,
Dave

-- 
You received this message because you are subscribed to the Google 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.



Group by date: Annotate & Aggregate Query

2011-03-24 Thread James Taylor
Hi,
We're trying to do some reports of various things, and one of the 
common issues we have is to do statistics on a per day or per-month basis - A 
google search for various terms finds quite a few stackoverflow people trying 
to do the same thing and not a lot of people are getting any success without 
reverting to rawsql, which I don't really want to do.

I've made the smallest example I can here (on the end of this email), which is 
a model file and a management command that goes with it. I've created two 
linked (one to many) models, 'Article' with many 'Comments' - I want to know 
how many comments have been made on each article per day (and preferably 
efficiently without having to do a query per day with a specific filter).

Effectively, the code that I think *should work* is is:

query = Comment.objects.values( "article__title",  
"made_at__year").annotate(comments=Count("pk"))

The error i get is:

" django.core.exceptions.FieldError: Cannot resolve keyword 'made_at__year' 
into field. Choices are: article, author, id, made_at, message "

What are my options?

Best Regards
JT

--
Smallest app demonstrating issue:

Models (stest/models.py)


from django.db import models

# Create your models here.

class Article (models.Model):
title = models.TextField()
body = models.TextField()

class Comment (models.Model):
message = models.TextField()
author = models.TextField()
made_at = models.DateTimeField()
article = models.ForeignKey(Article)

Command (stest/management/commands/stats.py)


from django.core.management.base import BaseCommand, CommandError
from django.db.models import Count
from stest.models import Article, Comment
from datetime import datetime

class Command(BaseCommand):
   args = ''
   help = 'Testing stats run'

   def handle(self, *args, **options):
   print "Running Stats"

   # Can use a filter to narrow down - but don't really mind in this 
instance
   # base_query = Comment.objects.filter(
   #made_at__gte=date_from,
   #made_at__lt=date_to
   #)

   # If I want to query per author per article (this works):
   query = Comment.objects.values( "article__title",  
"author").annotate(comments=Count("pk"))

   for row in query:
   print "%s : %s : %s comments" % (row["article__title"], 
row["author"], row["comments"])


   # if I want to query by day per article (this fails)
   query = Comment.objects.values( "article__title",  
"made_at__year").annotate(comments=Count("pk"))

   for row in query:
   print "%s : %s : %s comments" % (row["article__title"], 
row["made_at"], row["comments"])

   # django.core.exceptions.FieldError: Cannot resolve keyword 
'made_at__year' into field. Choices are: article, author, id, made_at, message

-- 
You received this message because you are subscribed to the Google 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: Generic Foreign Keys in fixtures

2011-03-24 Thread Simone Dalla
2011/3/24 LurkingFrog 

> Currently, I am writing unit tests for an application that uses
> generic foreign keys.  Since the contenttypes are regenerated every
> test, I was wondering the most effective way to reconcile the existing
> test data with the new contenttypes PKs.
>
> My current thinking is to make an explicit fixture the dumpdata from
> contenttypes at the same time I generate the other fixtures I plan to
> use in my tests.  From there, I will add code to manually update the
> content types in the database to the ones in the aforementioned
> contenttypes fixture and call it from the __init__.py in each
> application/tests folder.  Since that __init__.py should be called
> after the migrations are completed, this should make all the data line
> up.
>
> My question is whether this is the most efficient / effective way to
> solve this issue.
>
> Thanks,
> Dave


maybe option --natural

http://docs.djangoproject.com/en/1.3/ref/django-admin/#dumpdata-appname-appname-appname-model



-- 
Simo

- Registered Linux User #395060

- Software is like sex, it is better when it is free  --> Linus B. Torvalds

-- 
You received this message because you are subscribed to the Google 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: Generic Foreign Keys in fixtures

2011-03-24 Thread Shawn Milochik
On Thu, Mar 24, 2011 at 2:29 PM, Simone Dalla  wrote:
>
> maybe option --natural
> http://docs.djangoproject.com/en/1.3/ref/django-admin/#dumpdata-appname-appname-appname-model
>


Natural keys were introduced in 1.2. How would you do this in 1.1?

Or maybe there's a cleaner answer when the problem is re-stated:

How can you use dumpdata and loaddata to dump and reload fixtures when
you're using generic foreign keys?

(I work with the OP, so I'm not hijacking the thread).

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.



Check all foreign keys before delete.

2011-03-24 Thread pbzRPA
Hi,

I am constantly running in a brick wall when it comes to deleting
records in Django. If you have one or two foreign keys it is easy to
check if they are in use, but once an application starts getting big
you can not remember which models are making use of a foreign key and
if a specific foreign key is in use.

So my question: Is there a way to check if a single model record if
being used as a foreign key in all the models in a django project? For
example:

class Stage(models.Model):
description = mo.

class Document(models,Model):
stage = models.ForeignKey(Stage)

class Server(models.Model):
stage = models.ForeignKey(Stage)

Now when I do "stage = Stage.objects.get(pk=x)" is it possible for me
to do some like "stage.?" and get back true or false if "stage" is
being used either in Document or Server or any other class that uses
Stage as a foreign Key but also only for this 1 specific record.

All I really want to do is see if I can delete "stage" without it
effecting and other records in the database.

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: Check all foreign keys before delete.

2011-03-24 Thread Shawn Milochik
Once you have your 'stage' instance, try this:

stage._meta.get_all_related_objects()

You can get related models dynamically and check to see if there are
actually related instances for each of them.
Play with _meta in the shell and you'll find interesting and useful things.

Despite the underscore prefix, _meta is kept pretty stable and is used
often by normal users.

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: Check all foreign keys before delete.

2011-03-24 Thread pbzRPA
Hit the nail on the head :) Thank you very much for the quick
response. Problem solved.

-- 
You received this message because you are subscribed to the Google 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.



No id after save() in 1.3?

2011-03-24 Thread EAMiller
Trying to migrate from 1.1 to 1.3. My app is broken at the moment
because I'm not getting id's out of saved objects. I'm using
Postgresql/psycopg2.

I'm able to demonstrate in an ipython shell:

In [1]: import django

In [2]: django.get_version()
Out[2]: u'1.1.4 SVN-15632'

In [3]: u = User.objects.all()[0]

In [4]: ut = Utility(created_by=u, modified_by=u, name="Test1",
abbr="T1")

In [5]: ut.save()

In [6]: ut.id
Out[6]: 7L

I quit this session, and switch to 1.3, the do the same thing:

In [1]: import django

In [2]: django.get_version()
Out[2]: u'1.3 SVN-15912'

In [3]: u = User.objects.all()[0]

In [4]: ut = Utility(created_by=u, modified_by=u, name="Test2",
abbr="T2")

In [5]: ut.save()

In [6]: ut.id

In [7]: ut.id == None
Out[7]: True

And.. if I hope over to my psql shell, I can see that both were
created:

er-ca=# select * from er_utility where id > 6;
 id | modified_by_id | created_by_id |  modified_on
|  created_on   | name  | abbr | contact_id
++---+---
+---+---+--+
  7 | 11 |11 | 2011-03-24 12:02:04.341317-07 |
2011-03-24 12:02:04.341004-07 | Test1 | T1   |
  8 | 11 |11 | 2011-03-24 12:03:10.472508-07 |
2011-03-24 12:03:10.472456-07 | Test2 | T2   |


Any ideas what is going on here?

-- 
You received this message because you are subscribed to the Google 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: Check all foreign keys before delete.

2011-03-24 Thread Shawn Milochik
You're welcome.

I recommend (to any Django user) that you check out Marty Alchin's
"Pro Django."

Don't hesitate for a second because it was written in the ancient
times of Django 1.1 -- for Django to be changed enough that this book
becomes irrelevant it would take many years and drastic changes to the
internals of Django. This isn't a 'how-to' book like James Bennett's,
or a 'guide' like 'The Definitive Guide' by the BDFLs. It is a
serious, in-depth look that you don't need to use Django, but you want
to know to use Django effectively.

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: Failed to build documentation (solved)

2011-03-24 Thread Lic . José M . Rodriguez Bacallao
so, no one?

On Thu, Mar 24, 2011 at 11:42 AM, Lic. José M. Rodriguez Bacallao
 wrote:
> hey, I am using ubuntu 10.10, do I really need to update Sphinx to
> build documentation?
>
> On Thu, Mar 10, 2011 at 3:51 AM, Thomas Guettler  wrote:
>> Hi,
>>
>> the problem is solved, this is just for other people who have the same error.
>>
>> When you try to build the documentation and get the following error:
>>
>>
>>  File "/home/user/_django-trunk/docs/_ext/djangodocs.py", line 86, in run
>>    xrefs = roles.XRefRole()('doc', linktext, linktext, self.lineno, 
>> self.state)
>> AttributeError: 'module' object has no attribute 'XRefRole'
>>
>> You might be running an old version of Sphinx. Version 0.6 is not supported.
>>
>> You need to use the "-U" Option (update), to get the latest version:
>>
>> Example: easy_install -U --prefix=$HOME Sphinx
>>
>> Without -U easy_install copied the old version from /usr/lib into my home
>> directory.
>>
>>  HTH,
>>    Thomas Güttler
>>
>> --
>> Thomas Guettler, http://www.thomas-guettler.de/
>> E-Mail: guettli (*) thomas-guettler + de
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>>
>>
>
>
>
> --
> Lic. José M. Rodriguez Bacallao
> Centro de Biofisica Medica
> -
> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
>
> Recuerda: El arca de Noe fue construida por aficionados, el titanic
> por profesionales
> -
>



-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread Shawn Milochik
I can confirm that, for me, I get the ID back just fine when using
Django 1.3. My django.get_version() just returns '1.3' (without the
SVN commit ID).

I tested this on a project I'm developing in Django 1.3, so I haven't
tried these models with 1.1.

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: Generic Foreign Keys in fixtures

2011-03-24 Thread Simone Dalla
2011/3/24 Shawn Milochik 

> On Thu, Mar 24, 2011 at 2:29 PM, Simone Dalla  wrote:
> >
> > maybe option --natural
> >
> http://docs.djangoproject.com/en/1.3/ref/django-admin/#dumpdata-appname-appname-appname-model
> >
>
>
> Natural keys were introduced in 1.2. How would you do this in 1.1?
>

1.2

-- 
Simo

- Registered Linux User #395060

- Software is like sex, it is better when it is free  --> Linus B. Torvalds

-- 
You received this message because you are subscribed to the Google 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: Generic Foreign Keys in fixtures

2011-03-24 Thread Shawn Milochik
On Thu, Mar 24, 2011 at 3:29 PM, Simone Dalla  wrote:
>> Natural keys were introduced in 1.2. How would you do this in 1.1?
>
> 1.2
> --

You mean 1.3, right? ;o)

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread akaariai
On Mar 24, 9:07 pm, EAMiller  wrote:
> er-ca=# select * from er_utility where id > 6;
>  id | modified_by_id | created_by_id |          modified_on
> |          created_on           | name  | abbr | contact_id
> ++---+---
> +---+---+--+
>   7 |             11 |            11 | 2011-03-24 12:02:04.341317-07 |
> 2011-03-24 12:02:04.341004-07 | Test1 | T1   |
>   8 |             11 |            11 | 2011-03-24 12:03:10.472508-07 |
> 2011-03-24 12:03:10.472456-07 | Test2 | T2   |
>
> Any ideas what is going on here?

What does select pg_get_serial_sequence('er_utility', 'id') return?

 - Anssi

-- 
You received this message because you are subscribed to the Google 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.



Repetition in urls.py

2011-03-24 Thread Ryan Osborn
Hi,

I am using django 1.3 and have the following in my urls.py for a
blogging application:

urlpatterns = patterns('',
url(r'$',
ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_index'),
url(r'today/$',
TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_today'),
url(r'(?P\d{4})/$',
YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
url(r'(?P\d{4})/(?P[a-z]{3})/$',
MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/$',
DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/(?
P[\w\-]+)/$',
DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
)

I was just wondering if there was a simple way to condense this as
with django 1.2 I could add all this in to a dictionary like:

info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
10}

Ryan

-- 
You received this message because you are subscribed to the Google 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: Repetition in urls.py

2011-03-24 Thread Ian Clelland
On Thu, Mar 24, 2011 at 12:40 PM, Ryan Osborn  wrote:
> I was just wondering if there was a simple way to condense this as
> with django 1.2 I could add all this in to a dictionary like:
>
> info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
> 10}


Can you not set your info_dict just like that, and then rewrite it like this:

YearArchiveView.as_view(**info_dict),name='blog_archive_year'),
url(r'(?P\d{4})/(?P[a-z]{3})/$',


-- 
Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google 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: Check all foreign keys before delete.

2011-03-24 Thread pbzRPA
Great thanks, will definitely have a look.

-- 
You received this message because you are subscribed to the Google 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: Repetition in urls.py

2011-03-24 Thread akaariai


On Mar 24, 9:40 pm, Ryan Osborn  wrote:
> Hi,
>
> I am using django 1.3 and have the following in my urls.py for a
> blogging application:
>
> urlpatterns = patterns('',
>     url(r'$',
> ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
> name='blog_archive_index'),
>     url(r'today/$',
> TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
> name='blog_archive_today'),
>     url(r'(?P\d{4})/$',
> YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
>     url(r'(?P\d{4})/(?P[a-z]{3})/$',
> MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
>     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/$',
> DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
>     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/(?
> P[\w\-]+)/$',
> DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
> )
>
> I was just wondering if there was a simple way to condense this as
> with django 1.2 I could add all this in to a dictionary like:
>
> info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
> 10}
>
> Ryan

You can define the info_dict as above, and then use:
url(r'$', ArchiveIndexView.as_view(**info_dict),
name='blog_archive_index'), ...

 - Anssi

-- 
You received this message because you are subscribed to the Google 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: Repetition in urls.py

2011-03-24 Thread Ryan Osborn
Thanks guys, works great

On Mar 24, 7:54 pm, akaariai  wrote:
> On Mar 24, 9:40 pm, Ryan Osborn  wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I am using django 1.3 and have the following in my urls.py for a
> > blogging application:
>
> > urlpatterns = patterns('',
> >     url(r'$',
> > ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
> > name='blog_archive_index'),
> >     url(r'today/$',
> > TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
> > name='blog_archive_today'),
> >     url(r'(?P\d{4})/$',
> > YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/$',
> > MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/$',
> > DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/(?
> > P[\w\-]+)/$',
> > DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
> > )
>
> > I was just wondering if there was a simple way to condense this as
> > with django 1.2 I could add all this in to a dictionary like:
>
> > info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
> > 10}
>
> > Ryan
>
> You can define the info_dict as above, and then use:
> url(r'$', ArchiveIndexView.as_view(**info_dict),
> name='blog_archive_index'), ...
>
>  - Anssi

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread EAMiller


On Mar 24, 12:33 pm, akaariai  wrote:
> On Mar 24, 9:07 pm, EAMiller  wrote:
>
> > er-ca=# select * from er_utility where id > 6;
> >  id | modified_by_id | created_by_id |          modified_on
> > |          created_on           | name  | abbr | contact_id
> > ++---+---
> > +---+---+--+
> >   7 |             11 |            11 | 2011-03-24 12:02:04.341317-07 |
> > 2011-03-24 12:02:04.341004-07 | Test1 | T1   |
> >   8 |             11 |            11 | 2011-03-24 12:03:10.472508-07 |
> > 2011-03-24 12:03:10.472456-07 | Test2 | T2   |
>
> > Any ideas what is going on here?
>
> What does select pg_get_serial_sequence('er_utility', 'id') return?
>

er-ca=# select pg_get_serial_sequence('er_utility', 'id');
 pg_get_serial_sequence


(1 row)

-- 
You received this message because you are subscribed to the Google 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 & Two Factor Authentication (2FA)

2011-03-24 Thread Łukasz Rekucki
On 24 March 2011 14:50, pokecho  wrote:
> Hi Sam,
>
>
> So how do I configure contrib.auth to authenticate against three input
> values "username"(static), password(static/encrypted) and PIN/
> token(dynamic/encrypted)? That is the question.

As Sam already said, you need to write a custom authentication
backend[1] and use it instead of the default one.

Of course, you'll also need a custom form on your login page. If you
want to use the same system in Django's admin, you'll need to create
your own subclass of AdminSite and override the form and template
used[2].


[1]: 
http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend
[2]: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.login_form

-- 
Łukasz Rekucki

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



how to select tables in inspectdb?

2011-03-24 Thread Savio Sabino
Hi.
How I select what tables (in a db with 900 tables) has the model
generated for inpectdb?

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread EAMiller


On Mar 24, 1:00 pm, EAMiller  wrote:
> On Mar 24, 12:33 pm, akaariai  wrote:

> > What does select pg_get_serial_sequence('er_utility', 'id') return?
>
> er-ca=# select pg_get_serial_sequence('er_utility', 'id');
>  pg_get_serial_sequence
> 
>
> (1 row)

However, our id column is an integer, not a bigserial or serial. Is
that a 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: decorators and generic views

2011-03-24 Thread Łukasz Rekucki
On 24 March 2011 15:32, Ian Stokes-Rees  wrote:
> I think with the move to class-based Generic Views it is necessary to update
> this documentation:
>
> Limiting access to generic views
>
> To limit access to a generic view, write a thin wrapper around the view, and
> point your URLconf to your wrapper instead of the generic view itself. For
> example:
>
> from django.views.generic.date_based import object_detail
>
> @login_required
> def limited_object_detail(*args, **kwargs):
> return object_detail(*args, **kwargs)

Yeah, that probably needs an update. The topic guide on Class-based
Generic views has the right examples[1]:

### In URLconf, you can do:

from django.contrib.auth.decorators import login_required
from django.views.generic import TemplateView

urlpatterns = patterns('',

(r'^about/',login_required(TemplateView.as_view(template_name="secret.html"))),
)

### Decorating class:

from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView

class ProtectedView(TemplateView):
template_name = 'secret.html'

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(ProtectedView, self).dispatch(*args, **kwargs)

---

You can also decorate as_view(), like you tried to:

from django.contrib.auth.decorators import login_required
from django.utils.decorators import classonlymethod
from django.views.generic import TemplateView

class ProtectedView(TemplateView):

@classonlymethod
def as_view(cls, **initargs):
return login_required(super(ProtectedView, cls).as_view(**initargs))

This can be further abstracted into view_decorator() function[2].


[1]: 
http://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-the-class
[2]: 
https://github.com/lqc/django/blob/0eb2de3c156d8e6d1c31f46e0734af0ff06f93c4/django/utils/decorators.py#L46

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread akaariai
On Mar 24, 10:00 pm, EAMiller  wrote:
> er-ca=# select pg_get_serial_sequence('er_utility', 'id');
>  pg_get_serial_sequence
> 
>
> (1 row)

Ok, I think I know what is going on in here. For some reason (most
likely this is a hand made schema) the sequence which is used as the
default value of er_utility's id column is not owned by that column.
Hence pg_get_serial_sequence will return null, and this results in
currval(pg_get_serial_sequence('er_utility', 'id')) to return null.
This all is defined in django/db/backends/postgresql/operations.py:

def last_insert_id(self, cursor, table_name, pk_name):
# Use pg_get_serial_sequence to get the underlying sequence
name
# from the table name and column name (available since
PostgreSQL 8)
cursor.execute("SELECT
CURRVAL(pg_get_serial_sequence('%s','%s'))" % (
self.quote_name(table_name), pk_name))
return cursor.fetchone()[0]

Now, to fix this, first find out which sequence is used by
er_utility's id column (\d er_utility will help here). Then issue:

ALTER SEQUENCE seq_name OWNED BY er_utility, id;

Now everything should work as expected. If the same sequence is used
by multiple tables, there is unfortunately nothing you can do. A
sequence can be owned by only one column.

I will create a ticket about this problem.

 - Anssi

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



Re: how to select tables in inspectdb?

2011-03-24 Thread Jacob Kaplan-Moss
On Thu, Mar 24, 2011 at 3:07 PM, Savio Sabino  wrote:
> How I select what tables (in a db with 900 tables) has the model
> generated for inpectdb?

Sorry, but you can't: you'll need to run inspectdb and then edit the
generated code by hand to edit out the models you don't want.

Jacob

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



Re: No id after save() in 1.3?

2011-03-24 Thread EAMiller


On Mar 24, 1:23 pm, akaariai  wrote:
>
> Now, to fix this, first find out which sequence is used by
> er_utility's id column (\d er_utility will help here). Then issue:
>
> ALTER SEQUENCE seq_name OWNED BY er_utility, id;
>
> Now everything should work as expected.

I get

er-ca=# alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;
ERROR:  syntax error at or near ","
LINE 1: alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;
^
However, I'm not sure if your answer is based on the expectation that
we've got a serial or bigserial id column. It's an integer - although
as a colleague noted, if django 1.3 had created this table, it would
have been a serial. I haven't found any upgrade notes that describe
integer id columns as a 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: Failed to build documentation (solved)

2011-03-24 Thread Łukasz Rekucki
On 24 March 2011 20:15, Lic. José M. Rodriguez Bacallao
 wrote:
> so, no one?
>
> On Thu, Mar 24, 2011 at 11:42 AM, Lic. José M. Rodriguez Bacallao
>  wrote:
>> hey, I am using ubuntu 10.10, do I really need to update Sphinx to
>> build documentation?
>>

Yes, you do.

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread EAMiller


On Mar 24, 1:35 pm, EAMiller  wrote:

>
> er-ca=# alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;
> ERROR:  syntax error at or near ","
> LINE 1: alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;
>

wait, it's er_utility.id ... and that does work! thanks!

although it's not clear to me who owned the sequence before. Running
\d shows the same owner for those sequences before and after... :\

-- 
You received this message because you are subscribed to the Google 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: No id after save() in 1.3?

2011-03-24 Thread akaariai


On Mar 24, 10:35 pm, EAMiller  wrote:
> er-ca=# alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;
> ERROR:  syntax error at or near ","
> LINE 1: alter SEQUENCE er_utility_id_seq OWNED BY er_utility, id;

Sorry, my bad. er_utility, id should have been er_utility.id
                                      
> However, I'm not sure if your answer is based on the expectation that
> we've got a serial or bigserial id column. It's an integer - although
> as a colleague noted, if django 1.3 had created this table, it would
> have been a serial. I haven't found any upgrade notes that describe
> integer id columns as a problem.

I reported this to Trac, issue #15682.

id integer not null default nextval('er_utility_id_seq') is almost
like serial. From postgresql docs: [1]

CREATE TABLE tablename (
colname SERIAL
);

is equivalent to specifying:

CREATE SEQUENCE tablename_colname_seq;
CREATE TABLE tablename (
colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
);
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;

[1] 
http://www.postgresql.org/docs/8.4/static/datatype-numeric.html#DATATYPE-SERIAL

-- 
You received this message because you are subscribed to the Google 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: Group by date: Annotate & Aggregate Query

2011-03-24 Thread Casey Greene

Aggregation for dates is a feature that has a trac ticket:
http://code.djangoproject.com/ticket/10302

One option would be to implement this (it's also listed for google SoC 
2011 so maybe someone else will do it 
http://code.djangoproject.com/wiki/SummerOfCode2011#Improveannotationandaggregation 
).


Casey

On 03/24/2011 01:34 PM, James Taylor wrote:

Hi,
We're trying to do some reports of various things, and one of the 
common issues we have is to do statistics on a per day or per-month basis - A 
google search for various terms finds quite a few stackoverflow people trying 
to do the same thing and not a lot of people are getting any success without 
reverting to rawsql, which I don't really want to do.

I've made the smallest example I can here (on the end of this email), which is 
a model file and a management command that goes with it. I've created two 
linked (one to many) models, 'Article' with many 'Comments' - I want to know 
how many comments have been made on each article per day (and preferably 
efficiently without having to do a query per day with a specific filter).

Effectively, the code that I think *should work* is is:

query = Comment.objects.values( "article__title",  
"made_at__year").annotate(comments=Count("pk"))

The error i get is:

" django.core.exceptions.FieldError: Cannot resolve keyword 'made_at__year' into 
field. Choices are: article, author, id, made_at, message"

What are my options?

Best Regards
JT

--
Smallest app demonstrating issue:

Models (stest/models.py)


from django.db import models

# Create your models here.

class Article (models.Model):
title = models.TextField()
body = models.TextField()

class Comment (models.Model):
message = models.TextField()
author = models.TextField()
made_at = models.DateTimeField()
article = models.ForeignKey(Article)

Command (stest/management/commands/stats.py)


from django.core.management.base import BaseCommand, CommandError
from django.db.models import Count
from stest.models import Article, Comment
from datetime import datetime

class Command(BaseCommand):
args = ''
help = 'Testing stats run'

def handle(self, *args, **options):
print "Running Stats"

# Can use a filter to narrow down - but don't really mind in this 
instance
# base_query = Comment.objects.filter(
#made_at__gte=date_from,
#made_at__lt=date_to
#)

# If I want to query per author per article (this works):
query = Comment.objects.values( "article__title",  
"author").annotate(comments=Count("pk"))

for row in query:
print "%s : %s : %s comments" % (row["article__title"], row["author"], 
row["comments"])


# if I want to query by day per article (this fails)
query = Comment.objects.values( "article__title",  
"made_at__year").annotate(comments=Count("pk"))

for row in query:
print "%s : %s : %s comments" % (row["article__title"], row["made_at"], 
row["comments"])

# django.core.exceptions.FieldError: Cannot resolve keyword 
'made_at__year' into field. Choices are: article, author, id, made_at, message



--
You received this message because you are subscribed to the Google 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.



Templates are parsed on every request?

2011-03-24 Thread Fett
Hi,

I just had to implement some custom template tags, and figured out
that template files are parsed each time a request is received (more
precisely, I noticed this behavior while in debug mode, but didn't
expect to have it with debug = False).

I may have missed something, but I thought the only reason why parsing
(building a template node) and rendering (execute the node "render"
method) were two separated steps was because template was parsed only
once then stored in a "compiled" form. Django's cache framework
doesn't seem to be what I'm searching for, since if caches the entire
rendered template along with its dynamic context, thus shadows all
changes I make on printed variables unless I manually invalidate the
cache.

Did I miss the entire point of using Django templates? Since my
templates won't change once in production, parsing them on each
request wasn't exactly the way I planned to use my server CPU, but I
suppose I'm not doing it the right way ;)

Thanks for your help!

Regards,
F.

-- 
You received this message because you are subscribed to the Google 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: Templates are parsed on every request?

2011-03-24 Thread Karen Tracey
On Thu, Mar 24, 2011 at 5:09 PM, Fett  wrote:

> I just had to implement some custom template tags, and figured out
> that template files are parsed each time a request is received (more
> precisely, I noticed this behavior while in debug mode, but didn't
> expect to have it with debug = False).
>
> I may have missed something, but I thought the only reason why parsing
> (building a template node) and rendering (execute the node "render"
> method) were two separated steps was because template was parsed only
> once then stored in a "compiled" form. Django's cache framework
> doesn't seem to be what I'm searching for, since if caches the entire
> rendered template along with its dynamic context, thus shadows all
> changes I make on printed variables unless I manually invalidate the
> cache.
>
> Did I miss the entire point of using Django templates? Since my
> templates won't change once in production, parsing them on each
> request wasn't exactly the way I planned to use my server CPU, but I
> suppose I'm not doing it the right way ;)
>

You seem to have missed the cached template loader:

http://docs.djangoproject.com/en/1.3/ref/templates/api/#template-loaders

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

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



Re: Turning off USE_L10N more than doubled my site performance!

2011-03-24 Thread Karen Tracey
On Thu, Mar 24, 2011 at 10:46 AM, Carsten Fuchs wrote:

> I'd be very happy to learn what you make of this data (afaics, the problem
> could perfectly well be in my app code, not in Django).


First, do you really mean USE_I18N everywhere where you have USE_L10N?

The top cumtime item:

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
183330.7060.0004.3680.000
/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py:23(delayed_loader)

is one whose execution time will be vastly different depending on USE_I18N
value. I cannot figure out why it would be getting called more (or be more
expensive to call) with USE_L10N = True vs. False, so I'm thinking you must
have changed USE_I18N to see the dramatic performance difference? (There are
already notes in the doc that if you don't need translation you should turn
USE_I18N off, see:
http://docs.djangoproject.com/en/1.3/topics/i18n/deployment/#if-you-don-t-need-internationalization,
http://docs.djangoproject.com/en/1.3/ref/settings/#use-i18n.)

Second, have you tried running with 1.3? That top call listed in the first
report no longer exists, it was removed by the fix to this ticket:
http://code.djangoproject.com/ticket/14306, motivation being performance
improvement. So it would be interesting to see how your results compare with
the current release.

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

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



Looking for django interns

2011-03-24 Thread Ferrum26
Hey Group,
My groups site: www.couchconnect.com recently went public.  I'm a
django newb myself and still learning.  I'm looking for django
enthusiasts who would be interested in working on a publicly launched
social networking site done completely with django.  We can offer
intern credit, or other forms of compensation.  Shoot me a message if
you're interested. Thanks,
-Adriel
ferru...@gmail.com

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



Re: contenttypes installed but not ???

2011-03-24 Thread Jon Walsh
The error is caused by importing an additional settings module (into
settings.py).

I can't figure out why though... since they are mostly just variables
with string values...

-- 
You received this message because you are subscribed to the Google 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 & Two Factor Authentication (2FA)

2011-03-24 Thread pokecho
Hi Łukasz,

Thanks for the great advice and for pointing me to these resources.
I truly appreciate it.

Patrick.

On Mar 24, 4:03 pm, Łukasz Rekucki  wrote:
> On 24 March 2011 14:50, pokecho  wrote:
>
> > Hi Sam,
>
> > So how do I configure contrib.auth to authenticate against three input
> > values "username"(static), password(static/encrypted) and PIN/
> > token(dynamic/encrypted)? That is the question.
>
> As Sam already said, you need to write a custom authentication
> backend[1] and use it instead of the default one.
>
> Of course, you'll also need a custom form on your login page. If you
> want to use the same system in Django's admin, you'll need to create
> your own subclass of AdminSite and override the form and template
> used[2].
>
> [1]:http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authenti...
> [2]:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> --
> Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google 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: Admin theme started reverting to default

2011-03-24 Thread gondor
I went through and deleted all the pyc files and still seeing default
admin.

On Mar 24, 10:11 am, Artem  wrote:
> I had something similar with several test projects running on my
> machine.
> The problem was - auto-generated .pyc files in django sources.. one
> project user precompiled\precached files from another..
> I guess I mistakenly ran dev-servers with root account, so python
> could put .pyc files into that folder...
> I made a simple script to remove all pyc files from sources
>
> On 24 мар, 10:27, gondor  wrote:
>
>
>
> > I don't know if anyone has has this problem.  I have been using the
> > test django server and it has always rendered my customized admin
> > panel correctly.  One day out of the blue the admin panel just started
> > using the default.  I don't think I made any changes.  I understand
> > this is kind of vague but i'm looking for suggestions on what to look
> > for and where to look.
>
> > None of the template/admin/ admin template modifications are
> > visible...
>
> > (r'^(.*),admin.site.root)
>
> > Any suggestions or recommendations are very welcome.

-- 
You received this message because you are subscribed to the Google 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: Admin theme started reverting to default

2011-03-24 Thread Artem
All from project and from django source?
Try to remove all the pyc files from python packages, clear cache if
used, copy django into project folder, restart server.
If you really didn't change anything in sources it must be cache
problem at some level

On 25 мар, 06:28, gondor  wrote:
> I went through and deleted all the pyc files and still seeing default
> admin.
>
> On Mar 24, 10:11šam, Artem  wrote:
>
>
>
> > I had something similar with several test projects running on my
> > machine.
> > The problem was - auto-generated .pyc files in django sources.. one
> > project user precompiled\precached files from another..
> > I guess I mistakenly ran dev-servers with root account, so python
> > could put .pyc files into that folder...
> > I made a simple script to remove all pyc files from sources
>
> > On 24 ÍÁÒ, 10:27, gondor  wrote:
>
> > > I don't know if anyone has has this problem. šI have been using the
> > > test django server and it has always rendered my customized admin
> > > panel correctly. šOne day out of the blue the admin panel just started
> > > using the default. šI don't think I made any changes. šI understand
> > > this is kind of vague but i'm looking for suggestions on what to look
> > > for and where to look.
>
> > > None of the template/admin/ admin template modifications are
> > > visible...
>
> > > (r'^(.*),admin.site.root)
>
> > > Any suggestions or recommendations are very welcome.

-- 
You received this message because you are subscribed to the Google 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.