Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
Is this not possible? I wonder why Django force to upload files only
in a certain directory and doesn't allow more flexibility.



On 29 Set, 19:46, Federico Capoano  wrote:
> Hi everyone,
>
> is it possible to write a custom model filefield that upload files
> somewhere above the public directory?

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



Re: Upload above apache web root?

2010-09-30 Thread blaamann
On Sep 30, 9:49 am, Federico Capoano  wrote:
> Is this not possible? I wonder why Django force to upload files only
> in a certain directory and doesn't allow more flexibility.
>
> On 29 Set, 19:46, Federico Capoano  wrote:
>
> > Hi everyone,
>
> > is it possible to write a custom model filefield that upload files
> > somewhere above the public directory?

I haven't tried this myself, but a custom file storage might help you:
http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

or using a callback:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

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



Re: Upload above apache web root?

2010-09-30 Thread Xavier Ordoquy
Well, the documentation already tells you about it:
http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-filesystem-storage-class

Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :

> Is this not possible? I wonder why Django force to upload files only
> in a certain directory and doesn't allow more flexibility.
> 
> 
> 
> On 29 Set, 19:46, Federico Capoano  wrote:
>> Hi everyone,
>> 
>> is it possible to write a custom model filefield that upload files
>> somewhere above the public directory?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
Yes you're right, I'm trying it out. I'll post a solution when I'm
done.


On 30 Set, 10:10, Xavier Ordoquy  wrote:
> Well, the documentation already tells you about 
> it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
>
>
> > Is this not possible? I wonder why Django force to upload files only
> > in a certain directory and doesn't allow more flexibility.
>
> > On 29 Set, 19:46, Federico Capoano  wrote:
> >> Hi everyone,
>
> >> is it possible to write a custom model filefield that upload files
> >> somewhere above the public directory?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
PS: i'll post a solution so other noobs like me will see how to do
that..


On 30 Set, 10:35, Federico Capoano  wrote:
> Yes you're right, I'm trying it out. I'll post a solution when I'm
> done.
>
> On 30 Set, 10:10, Xavier Ordoquy  wrote:
>
>
>
> > Well, the documentation already tells you about 
> > it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> > Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
> > > Is this not possible? I wonder why Django force to upload files only
> > > in a certain directory and doesn't allow more flexibility.
>
> > > On 29 Set, 19:46, Federico Capoano  wrote:
> > >> Hi everyone,
>
> > >> is it possible to write a custom model filefield that upload files
> > >> somewhere above the public directory?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Upload above apache web root?

2010-09-30 Thread Xavier Ordoquy
Hi,

To me, it looks like the documentation already gave the answer.

Regards,
Xavier.

Le 30 sept. 2010 à 10:37, Federico Capoano a écrit :

> PS: i'll post a solution so other noobs like me will see how to do
> that..
> 
> 
> On 30 Set, 10:35, Federico Capoano  wrote:
>> Yes you're right, I'm trying it out. I'll post a solution when I'm
>> done.
>> 
>> On 30 Set, 10:10, Xavier Ordoquy  wrote:
>> 
>> 
>> 
>>> Well, the documentation already tells you about 
>>> it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>> 
>>> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>> 
 Is this not possible? I wonder why Django force to upload files only
 in a certain directory and doesn't allow more flexibility.
>> 
 On 29 Set, 19:46, Federico Capoano  wrote:
> Hi everyone,
>> 
> is it possible to write a custom model filefield that upload files
> somewhere above the public directory?
>> 
 --
 You received this message because you are subscribed to the Google Groups 
 "Django users" group.
 To post to this group, send email to django-us...@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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



iPhone posting FILEs = "Invalid content length"

2010-09-30 Thread Danny Bos

Hey there,
I've got a new error I'm totally stumped on. All searches are saying
it's a "http vs https" or similar.
I'd be keen to hear your thoughts.

Basically I've got an iPhone app sending a POST to a django app, it
contains one FILE.
Every now and then (very sporadically, about 1 in 5) one fails and I
get the below message.


Exception Type:
MultiPartParserError


Exception Value:
Invalid content length: 0


Exception Location:
/home/72999/data/python/django/django/http/multipartparser.py in
_init_, line 80


Any ideas?

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



Django app that uploads media files and servers them through a view?

2010-09-30 Thread Stodge
Is anyone aware of a Django app that lets you upload media files (not
necessarily in the admin site) but serves them through a view instead
of as static files via the web server? I need to control access to the
media using permissions. Thanks

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



Re: iPhone posting FILEs = "Invalid content length"

2010-09-30 Thread Carlton Gibson

On 30 Sep 2010, at 11:55, Danny Bos wrote:
> Basically I've got an iPhone app sending a POST to a django app, it
> contains one FILE.
> Every now and then (very sporadically, about 1 in 5) one fails and I
> get the below message.

> Exception Value:
> Invalid content length: 0

> Any ideas?

This will be a problem with your Objective-C code on the iPhone. Can you paste 
the code you're using to build the HTTP request? 

In want of that, I'd hazard that whatever method you're using to build the 
request body is returning nil, and that you're then assigning that as the 
request body. As such you're ending up with a content length of 0.

(Of course it could be something else entirely, but it doesn't sound like a 
Django issue per se.)

HTH

Regards,
Carlton

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



Re: Django app that uploads media files and servers them through a view?

2010-09-30 Thread Thomas Weholt
On Thu, Sep 30, 2010 at 1:20 PM, Stodge  wrote:
> Is anyone aware of a Django app that lets you upload media files (not
> necessarily in the admin site) but serves them through a view instead
> of as static files via the web server? I need to control access to the
> media using permissions. Thanks

Serving media using views are very inefficient, but I`m facing the
same problem; how to serve media using better suited servers like
nginx for media but still having some way of checking
permissions/authentication etc. ??

I`m working on a project similar to Windows Home Server, where users
can upload and backup their media and access it through a web
interface. Serving static media using django was terrible and using
nginx was incredibly fast, but I lost all access control to the static
media.

Any help on this subject would be highly appreciated.

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Re: Separating application media from project media

2010-09-30 Thread Benedict Verheyen
On 29/09/2010 13:58, Benedict Verheyen wrote:
> On 29/09/2010 13:13, David De La Harpe Golden wrote:
>> On 29/09/10 09:34, Benedict Verheyen wrote:
>>
>>> In my template i add this:
>>> >> href="{{MEDIA_URL_CALLTRACKING}}/style/login.css" />
>>>
>>
>> (I'd favour prefix rather than suffix if you're going to pseudo-namespace)
>>
>> Did you introduce such a MEDIA_URL_CALLTRACKING variable into the
>> template context by any means?  It's not automatic.  For MEDIA_URL, the
>> value in your settings is propagated into the template context by
>> django.core.context_processors.media, which you'll see is a
>> TEMPLATE_CONTEXT_PROCESSORS entry in settings.py
>>
>> If you want to duplicate that functionality for another variable, it's
>> straightforward enough to write a template context processor to do that
>> if you want to, see source.
>>
>> http://code.djangoproject.com/browser/django/trunk/django/core/context_processors.py#L69
>>
>> n.b. template context processors only work for RequestContext contexts,
>> which not everything uses (obviously for your own apps you can just make
>> sure to use them).
>>
>> FWIW, that's not the pattern the admin contrib follows, it uses  a
>> custom template tag library that includes a custom tag that resolves to
>> the admin media prefix, so its templates
>> do a
>> {% load adminmedia %} to load the tag library then they use
>> "{% admin_media_prefix %}blah/blah"
>>
>> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templatetags/adminmedia.py
>>
>> I have no particular opinion on what approach is better, both work.
> 
> Thanks,
> 
> 
> both seem solutions to what i'm trying to do. I'll try them out and report 
> back
> if it works.
> 
> Regards,
> Benedict

Hi,

i went for the template tag approach.
The template context processor would put an application specific variable 
available
for all other applications in this project and that didn't feel right.

The template tag allows for a certain variable to be available only to the 
application.
That's why i choose it.
Another benefit is that other developers see that you included something extra 
and thus
know about the variable. If you use a template context processor, the var is
auto magically added and a developer might miss the fact that this var is
available for use.
Of course you have documentation but the chances are that somebody misses it.

Regards,
Benedict


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



Re: Separating application media from project media

2010-09-30 Thread Benedict Verheyen
On 29/09/2010 18:55, Carles Barrobés wrote:
> At some point I also thought this was a good idea. This way I can
> reuse the app and all its visual stuff as well.
> 
> But the problem is that for most cases you will want your templates
> and media to be consistent with a site's design and look&feel. This
> means that for two projects (sites) re-using the same application, the
> styles/icons etc are bound to be quite different. On the one hand it
> is already hard to create a template that can be reused in many
> different pages/layouts (normally for each site you will have a
> different base template and a specific template hierarchy, etc). And
> besides including specific stylesheets... which are bound to clash
> with styles from the base site...
> 
> Unless you want to do something like the admin, which really looks
> like a different site and doesn't have anything to do with the rest of
> your site's look & feel, but which we don't care because we don't mind
> it really looking like a separate entity, since it is typically not
> available to end users.
> 
> I don't know what your use case is and how you are going to tackle the
> difficulties I found. I in fact went the opposite way you're going,
> moving templates and styles to the project and keeping only the
> functionality for the app, because the templates and styles I needed
> ended up being quite coupled with the rest of the site.
> 
> I'm interested to know how you solve this, or if it matters to you.
> 
> Carles.

Hi Carles,


i find the whole project, app idea a bit confusing for my case.
It might help if I describe my use case first.

I'm building a set of applications that will be available to our users.
Users being company employees so no external users.
The start page is what I call a dashboard. It's basically a page with
tabs that represent different departments.
For instance ICT, Accountancy, and so on.
If you click on a tab, you'll see icons that link to a certain application.
For instance, you click on the ICT tab, you'll see an icon linked
to the calltracking application.

These applications are all very different. The first one, is a calltracking
system for ICT that allows users to see what we are doing for a certain
problem and allows us to follow up the calls.

The first problem i had was login. I want the users to login once
and if they switch to a different application, then they should remain
logged in.

That's how i ended up with a project "dashboard" and an application
"calltracking". The authentication code is located in the project, all
the calltracking files are in the calltracking directory.
Any other application, will be treated the same way as the calltracking.
Making an app and putting all related files in there.
The authentication for a new app is handled already then by the project.

A point of doubt i had when structuring the code was that  the whole project/app
concept is clear when you talk about a site having a blog, a news app and so on.
But my applications are totally different and don't necessary belong to a 
"site".
The application IS a site. The only thing they have in common is the central 
login.
So style isn't an issue for me and a such, it makes more sense to put the media
and templates in the application directory.
This makes the application more portable.
But it still doesn't feel completely right.

The media is a problem however. I found a solution by putting a settings.py file
in the application directory. That settings file is imported in the projects 
settings file.
I've defined a MEDIA_URL & MEDIA_ROOT variable in the application settings file.
I actually named them MEDIA_URL_CALLTRACKING and
MEDIA_ROOT_CALLTRACKING and made a template tag that
makes them available in my calltracking templates.

I could have made a template context processor but that would make these
var's available in other applications and that didn't feel right so i choose
to use the template tag approach.
It works OK, but i could even make it simpler but that is very hackish:
in the tag, you can change the MEDIA_URL to the media URL of the caltracking.
Bonus: you can still use {{ MEDIA_URL }} in the templates instead of using
{% MEDIA_URL_CALLTRACKING %}
Like i said, this feels hackish and makes me doubt if i'm using the
whole project/app concept correctly.

If i would want to release my code for other people to use, it makes
more sense to distribute it as an application than as a project.
It's all confusion, that's why I think there should be a page on Django
that explains a few use cases and how code could then best be structured.

Another approach might have been to make a static dashboard page
instead of a project and make a project and app dir for every application.
But I don't know how I could manage a central login system then as
the cookies/sessions aren't shared across projects I think.

Anyway, i was able to put the templates and media in the application
in the end but since it was so much trouble, it probably means it'

Re: Django app that uploads media files and servers them through a view?

2010-09-30 Thread Jirka Vejrazka
>> Is anyone aware of a Django app that lets you upload media files (not
>> necessarily in the admin site) but serves them through a view instead
>> of as static files via the web server? I need to control access to the
>> media using permissions. Thanks
>
> Serving media using views are very inefficient, but I`m facing the
> same problem; how to serve media using better suited servers like
> nginx for media but still having some way of checking
> permissions/authentication etc. ??
>
> I`m working on a project similar to Windows Home Server, where users
> can upload and backup their media and access it through a web
> interface. Serving static media using django was terrible and using
> nginx was incredibly fast, but I lost all access control to the static
> media.

  Hi there,

  while I don't have first-hand experience, I do remember (from
EuDjangoCon) that this can be achieved quite effectively using
perlbal's reproxy feature. It does not handle the "upload" part, but
that should not be difficult to code using Django's file upload
mechanisms or 3rd party packages.

  Just my 2 cents, that's where I'd start looking if I needed this...

  Cheers

Jirka

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



Re: Django app that uploads media files and servers them through a view?

2010-09-30 Thread Xavier Ordoquy
Hi,

Although I haven't done it, the following link may give you a good overview of 
how to do it:
http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/

Regards,
Xavier.

Le 30 sept. 2010 à 13:34, Thomas Weholt a écrit :

> On Thu, Sep 30, 2010 at 1:20 PM, Stodge  wrote:
>> Is anyone aware of a Django app that lets you upload media files (not
>> necessarily in the admin site) but serves them through a view instead
>> of as static files via the web server? I need to control access to the
>> media using permissions. Thanks
> 
> Serving media using views are very inefficient, but I`m facing the
> same problem; how to serve media using better suited servers like
> nginx for media but still having some way of checking
> permissions/authentication etc. ??
> 
> I`m working on a project similar to Windows Home Server, where users
> can upload and backup their media and access it through a web
> interface. Serving static media using django was terrible and using
> nginx was incredibly fast, but I lost all access control to the static
> media.
> 
> Any help on this subject would be highly appreciated.
> 
> -- 
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.org
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-09-30 Thread Jyrki Pulliainen
Hi!

We encountered a possible backwards incompatibility with change 12950
[1]. This was noticed when upgrading from 1.1.1 to 1.1.2.

If I understand correctly the change 12950 removes squelching of
ImportErrors from AppCache. AppCache in turn provides reverse-
relations for app introspection, for example in admin interface. This
change now causes the ImportError in one otherwise fine case to
propagate and break the application.

Funnily enough, this does not break our application per se. The webapp
still continues to work with admin interface fully responsive, doing
all the changes wanted, tests passing etc. This only affects a smaller
worker script that is run via upstart.

This upstart script imported a single model class (let's say, model
class A) from a single app. However, this models.py file also had
another model (class C) and it's admin definitions (there was actually
no change even if these were moved to separate admin.py, we have a
custom AdminSite object). For some reason importing this single caused
the import error to fire. And as said before this behavior doesn't
surface for example when running ./manage.py runserver, only trying to
start the worker script causes the ImportError.

Unfortunately this software isn't open source, but I think I can
describe the module layout a bit though:

Class A -- the "troublemaker" class has a reverse relationship with
class B from another app, ie. class B has ForeignKeyField to A.
Neither of these classes has any admin interface and they're not
registered to the admin site object
Class C -- another model in the same models.py (and app) as Class A.
This is registed to the AdminSite.

Now, when the worker starts the importing of class A causes
ImportError due to the admin site trying to import stuff in AppCache,
even it is not needed. The models.py it is trying to import when
crashing is the models.py containing the Class B.

Hopefully this description is even a bit helpful, even though it's a
hard to get the whole picture without the code.

My 2 euro-cents here is that starting the server with runserver (or as
fastcgi, we've tested that too) does the imports in correct order. It
imports the applications and inserts them in sys.modules in orderly
fashion without causing any illegal circular import Python can't
handle. But when not using the normal startup procedure of manage.py
runserver and instead just directly importing one of the models the
admin site importing goes fubar and ends up in circular import. The
old implementation just swallowed this importerror and let the worker
to continue normally. This is the reason why I think this is a change
that breaks backwards compatibility in this rare case.

For the record, we fixed this, but it caused some extra complexity to
our application as we had to split stuff in multiple dummy files for
importing certain stuff that previously worked and we also needed to
do some overhaul to the way we built our admin site. So everything is
now working :)

[1] http://code.djangoproject.com/changeset/12950

- Jyrki

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



Re: ANN: PyMySQL 0.3

2010-09-30 Thread Andy
Great!

Thank you very much.

On Sep 29, 6:56 pm, Bo Shi  wrote:
> The following patch to your application's manage.py will allow you to
> use pymysql without patching Django.
>
>  #!/usr/bin/env python
> +try:
> +    import pymysql
> +    pymysql.install_as_MySQLdb()
> +except ImportError:
> +    pass
> +
>
> On Sep 10, 12:25 pm, Andy  wrote:
>
> > On Sep 10, 11:18 am, Andy Dustman  wrote:
>
> > > Uh, no.
>
> > > MySQLdb releases the GIL on any blocking call, so other threads can run.
>
> > > Django is *not* asynchronous. It's threaded.
>
> > The default Django behavior is threaded.
>
> > But it can be made to run in async mode, where socket communication
> > doesn't block. That way one Django thread can serve multiple users
> > concurrently.
>
> > Check out gevent for details.
>
>

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



Tabular output

2010-09-30 Thread Martin Tiršel

Hello,

I have a list of images from database I need to print in a table and this  
seems to be more difficult as I expected. Is there an easy way how to  
print results into table? Number of collumns depends on a constant in  
settings.


Thanks,
Martin

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



Re: UnicodeEncodeError

2010-09-30 Thread Karen Tracey
On Wed, Sep 29, 2010 at 12:59 PM, jean polo wrote:

> Hi.
> I get an 'UnicodeEncodeError' if I upload a file (ImageField) with non-
> ascii chars in my application (django-1.2.1).
>
> I added:
>
> export LANG='en_US.UTF-8'
> export LC_ALL='en_US.UTF-8'
>
> in my /etc/apache2/envvars as stated here:
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror
>
> but I still have the same error (after restarting apache).
> Any hint much appreciated.
>
>
Some servers do not have the necessary language files to allow successfully
setting the locale to one that supports utf-8 encoding. See the very last
sentence here: http://code.djangoproject.com/wiki/ExpectedTestFailures

You should be able to experiment with setting these variables in a shell
session and passing unicode strings containing non-ASCII characters to file
system routines like stat. If it works in a shell, then likely you've got
the necessary language support installed, and the problem then is that the
Apache configuration for some reason is not taking effect. If you cannot get
it to work in a shell either, then likely you are missing a language pack
that would allow successfully setting locale in this way.

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

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



Re: Tabular output

2010-09-30 Thread Xavier Ordoquy
Hi,

Could you elaborate on your issue ?
If you have hard time positionning  you can loop on you list items and use 
loop.counter or loop.counter0 and use the divisibleby tag to display line start 
and end

Regards,
Xavier.

Le 30 sept. 2010 à 14:15, Martin Tiršel a écrit :

> Hello,
> 
> I have a list of images from database I need to print in a table and this 
> seems to be more difficult as I expected. Is there an easy way how to print 
> results into table? Number of collumns depends on a constant in settings.
> 
> Thanks,
> Martin
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-09-30 Thread Karen Tracey
On Thu, Sep 30, 2010 at 8:01 AM, Jyrki Pulliainen  wrote:

> We encountered a possible backwards incompatibility with change 12950
> [1]. This was noticed when upgrading from 1.1.1 to 1.1.2.
>
> If I understand correctly the change 12950 removes squelching of
> ImportErrors from AppCache. AppCache in turn provides reverse-
> relations for app introspection, for example in admin interface. This
> change now causes the ImportError in one otherwise fine case to
> propagate and break the application.
>
> Funnily enough, this does not break our application per se. The webapp
> still continues to work with admin interface fully responsive, doing
> all the changes wanted, tests passing etc. This only affects a smaller
> worker script that is run via upstart.
>

[additional info skipped]

Without specifics (at least a traceback from the error) it's virtually
impossible to say whether the problem you encountered was a flaw in this
changeset or an error in the application. The original fix here was updated
based on user feedback, see for example
http://code.djangoproject.com/ticket/13335. There may also have been at
least one other like that but I don't recall exactly and do not have time to
search now. So far as I know the version of the change that appears in a
released version only reports true application errors (e.g. circular
imports) that really should never have been suppressed in the first place.

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

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



TemplateSyntaxError at /accounts/register/ Invalid filter: 'apnumber'

2010-09-30 Thread prakashadm
Hello friends,

I have getting below error

TemplateSyntaxError at /accounts/register/

Invalid filter: 'apnumber'

i am working on simple user registration of page.any budy have idea
abt it?

http://www.stonemind.net/blog/2007/04/13/django-registration-for-newbies/



thanks
Prakash

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



Re: Django app that uploads media files and servers them through a view?

2010-09-30 Thread Thomas Weholt
On Thu, Sep 30, 2010 at 1:52 PM, Xavier Ordoquy  wrote:
> Hi,
>
> Although I haven't done it, the following link may give you a good overview 
> of how to do it:
> http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/
>
> Regards,
> Xavier.
>
> Le 30 sept. 2010 à 13:34, Thomas Weholt a écrit :
>
>> On Thu, Sep 30, 2010 at 1:20 PM, Stodge  wrote:
>>> Is anyone aware of a Django app that lets you upload media files (not
>>> necessarily in the admin site) but serves them through a view instead
>>> of as static files via the web server? I need to control access to the
>>> media using permissions. Thanks
>>
>> Serving media using views are very inefficient, but I`m facing the
>> same problem; how to serve media using better suited servers like
>> nginx for media but still having some way of checking
>> permissions/authentication etc. ??
>>
>> I`m working on a project similar to Windows Home Server, where users
>> can upload and backup their media and access it through a web
>> interface. Serving static media using django was terrible and using
>> nginx was incredibly fast, but I lost all access control to the static
>> media.
>>
>> Any help on this subject would be highly appreciated.

This might help. Haven`t tested it: http://djangosnippets.org/snippets/491/

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



Re: Tabular output

2010-09-30 Thread Martin Tiršel
Thanks, this looks better, but one more thing - If I have for example 3  
columns and 13 images, I end with:



  


what is not a correct table. I need to insert two more TDs or one with  
colspan. Is there a solution for this?


Martin

On Thu, 30 Sep 2010 14:31:48 +0200, Xavier Ordoquy   
wrote:



Hi,

Could you elaborate on your issue ?
If you have hard time positionning  you can loop on you list items  
and use loop.counter or loop.counter0 and use the divisibleby tag to  
display line start and end


Regards,
Xavier.

Le 30 sept. 2010 à 14:15, Martin Tiršel a écrit :


Hello,

I have a list of images from database I need to print in a table and  
this seems to be more difficult as I expected. Is there an easy way how  
to print results into table? Number of collumns depends on a constant  
in settings.


Thanks,
Martin

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

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




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



Re: Tabular output

2010-09-30 Thread Carlton Gibson
I think it's not a problem. 

I just ran this via the (HTML5) validator and it didn't complain:



cell1
cell2


cell1



Regards,
Carlton

On 30 Sep 2010, at 13:49, Martin Tiršel wrote:

> Thanks, this looks better, but one more thing - If I have for example 3 
> columns and 13 images, I end with:
> 
> 
>  
> 
> 
> what is not a correct table. I need to insert two more TDs or one with 
> colspan. Is there a solution for this?
> 
> Martin
> 
> On Thu, 30 Sep 2010 14:31:48 +0200, Xavier Ordoquy  
> wrote:
> 
>> Hi,
>> 
>> Could you elaborate on your issue ?
>> If you have hard time positionning  you can loop on you list items and 
>> use loop.counter or loop.counter0 and use the divisibleby tag to display 
>> line start and end
>> 
>> Regards,
>> Xavier.
>> 
>> Le 30 sept. 2010 à 14:15, Martin Tiršel a écrit :
>> 
>>> Hello,
>>> 
>>> I have a list of images from database I need to print in a table and this 
>>> seems to be more difficult as I expected. Is there an easy way how to print 
>>> results into table? Number of collumns depends on a constant in settings.
>>> 
>>> Thanks,
>>> Martin
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: TemplateSyntaxError at /accounts/register/ Invalid filter: 'apnumber'

2010-09-30 Thread Daniel Roseman
On Sep 30, 1:14 pm, prakashadm  wrote:
> Hello friends,
>
> I have getting below error
>
> TemplateSyntaxError at /accounts/register/
>
> Invalid filter: 'apnumber'
>
> i am working on simple user registration of page.any budy have idea
> abt it?
>
> http://www.stonemind.net/blog/2007/04/13/django-registration-for-newb...
>
> thanks
> Prakash

The apnumber filter is part of the humanize templatetag library. Have
you done {% load humanize %} in your template?
--
DR.

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



Re: TemplateSyntaxError at /accounts/register/ Invalid filter: 'apnumber'

2010-09-30 Thread prakashadm
Hello

i have removed from {% load humanize %} from my mail activation code..
then it's given me below error

Thanks
Prakash
On Sep 30, 5:56 pm, Daniel Roseman  wrote:
> On Sep 30, 1:14 pm, prakashadm  wrote:
>
> > Hello friends,
>
> > I have getting below error
>
> > TemplateSyntaxError at /accounts/register/
>
> > Invalid filter: 'apnumber'
>
> > i am working on simple user registration of page.any budy have idea
> > abt it?
>
> >http://www.stonemind.net/blog/2007/04/13/django-registration-for-newb...
>
> > thanks
> > Prakash
>
> The apnumber filter is part of the humanize templatetag library. Have
> you done {% load humanize %} in your template?
> --
> DR.

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



Re: Tabular output

2010-09-30 Thread Martin Tiršel
Sorry, my bad, I thought that it has to be completed, so it is ok. Problem  
would be only if I wanted to make cell borderds, around the empty cells  
too.


Thanks,
Martin

On Thu, 30 Sep 2010 14:53:11 +0200, Carlton Gibson  
 wrote:



I think it's not a problem.

I just ran this via the (HTML5) validator and it didn't complain:



cell1
cell2


cell1



Regards,
Carlton

On 30 Sep 2010, at 13:49, Martin Tiršel wrote:

Thanks, this looks better, but one more thing - If I have for example 3  
columns and 13 images, I end with:



 


what is not a correct table. I need to insert two more TDs or one with  
colspan. Is there a solution for this?


Martin

On Thu, 30 Sep 2010 14:31:48 +0200, Xavier Ordoquy  
 wrote:


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



Re: Tabular output

2010-09-30 Thread aid


On Sep 30, 2:14 pm, Martin Tiršel  wrote:
> Sorry, my bad, I thought that it has to be completed, so it is ok. Problem  
> would be only if I wanted to make cell borderds, around the empty cells  
> too.

For the cells you don't have an  object to insert; try inserting
' ' instead. (Minus quotes!)  This tends to solve the border
problems.

Cheers,

aid

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



Need opinion for an object permission rule backend

2010-09-30 Thread Miguel Araujo
 Hi everyone,

I have been recently thinking about an object permission system. After
reviewing Florian Apolloner (apollo13) patch for ticket
#11010 and
reading his article at Django
Advent.
I though about creating an Object Permission Rule Backend. The purpose of
this message is explain you my idea, so I can receive feedback from Django
users and developers. This way I would like to discern if it's worth coding
it or if it's a good approach to a reusable solution.

I will reuse apollo's code to elaborate my idea. My Backend would look
similar to:

class ObjectPermBackend(object):
supports_object_permissions = True
supports_anonymous_user = True

def authenticate(self, username, password):
return None

def has_perm(self, user_obj, perm, obj=None):
if not user_obj.is_authenticated():
user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)

if obj is None:
return False

ct = ContentType.objects.get_for_model(obj)

try:
perm = perm.split('.')[-1].split('_')[0]
except IndexError:
return False

# Simplified rule system
# Of course objects should extend an interface
if (perm == "ownage")
return obj.is_owned_by(user_obj)

elif (perm == "edit")
return obj.can_be_edited_by(user_obj)

# Here be Dragons

As I love decorators, I would like to create a permission_required decorator
that accepted more than a parameter, so:

@permission_required('app.code_name') would
become @permission_required('app.code_name', FLAG)

If the FLAG is set the decorator searches in the model associated to the
content type of the permission, for the name of the field for the PK. For
the example imagine idArticle. Now it instantiates an object of that model
with Model.objects.get(pk=request.idArticle). So it would be necessary to
match request parameters to model fileds (This is the best idea I've come up
with). Once it has the right object, it passes it to the backend for
permission checks.

I know I could do a decorator like @own_article but I'm looking for a more
reusable solution, that I would make open source and release at Github.

What do you think? Is it feasible and well laid out?

Thanks, best regards
Miguel Araujo

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



Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-09-30 Thread Jyrki Pulliainen
On Sep 30, 3:38 pm, Karen Tracey  wrote:
> On Thu, Sep 30, 2010 at 8:01 AM, Jyrki Pulliainen  wrote:
> > We encountered a possible backwards incompatibility with change 12950
> > [1]. This was noticed when upgrading from 1.1.1 to 1.1.2.
>
> > If I understand correctly the change 12950 removes squelching of
> > ImportErrors from AppCache. AppCache in turn provides reverse-
> > relations for app introspection, for example in admin interface. This
> > change now causes the ImportError in one otherwise fine case to
> > propagate and break the application.
>
> > Funnily enough, this does not break our application per se. The webapp
> > still continues to work with admin interface fully responsive, doing
> > all the changes wanted, tests passing etc. This only affects a smaller
> > worker script that is run via upstart.
>
> [additional info skipped]
>
> Without specifics (at least a traceback from the error) it's virtually
> impossible to say whether the problem you encountered was a flaw in this
> changeset or an error in the application. The original fix here was updated
> based on user feedback, see for 
> examplehttp://code.djangoproject.com/ticket/13335. There may also have been at
> least one other like that but I don't recall exactly and do not have time to
> search now. So far as I know the version of the change that appears in a
> released version only reports true application errors (e.g. circular
> imports) that really should never have been suppressed in the first place.

Traceback follows:

Traceback (most recent call last):
  File "./bin/icm-init-worker", line 4, in 
from inoi.management.central.node_manager.workers import
InitWorker
  File "/home/jyrki/local/lib/python2.6/site-packages/inoi/management/
central/node_manager/workers.py", line 3, in 
from .models import Node
  File "/home/jyrki/local/lib/python2.6/site-packages/inoi/management/
central/node_manager/models.py", line 24, in 
from inoi.management.central import admin
  File "/home/jyrki/local/lib/python2.6/site-packages/inoi/management/
central/admin.py", line 34, in 
site.register(Group)
  File "/home/jyrki/local/lib/python2.6/site-packages/django/contrib/
admin/sites.py", line 90, in register
validate(admin_class, model)
  File "/home/jyrki/local/lib/python2.6/site-packages/django/contrib/
admin/validation.py", line 22, in validate
models.get_apps()
  File "/home/jyrki/local/lib/python2.6/site-packages/django/db/models/
loading.py", line 114, in get_apps
self._populate()
  File "/home/jyrki/local/lib/python2.6/site-packages/django/db/models/
loading.py", line 63, in _populate
self.load_app(app_name)
  File "/home/jyrki/local/lib/python2.6/site-packages/django/db/models/
loading.py", line 77, in load_app
models = import_module('.models', app_name)
  File "/home/jyrki/local/lib/python2.6/site-packages/django/utils/
importlib.py", line 35, in import_module
__import__(name)
  File "/home/jyrki/local/lib/python2.6/site-packages/inoi/management/
central/node_manager/firmware/models.py", line 5, in 
from inoi.management.central.node_manager.models import (
ImportError: cannot import name Node

- Jyrki

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



Help Reading data from an uploaded CSV

2010-09-30 Thread Chris McComas
I have this code:

http://dpaste.com/250981/

The file is uploading properly, but it is not creating any entries in
my Pharmcas table, it's worked before, last spring when we used it
last, but right now it's not working? It uploads and saves the file as
it should, but then doesn't do any of the creating of entries in the
table?

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



Re: Help Reading data from an uploaded CSV

2010-09-30 Thread Tom Evans
You have code like this

try:
   
except:
  pass

around the pertinent block. Perhaps not suppressing errors might
indicate where your code is failing.

Cheers

Tom

On Thu, Sep 30, 2010 at 3:09 PM, Chris McComas  wrote:
> I have this code:
>
> http://dpaste.com/250981/
>
> The file is uploading properly, but it is not creating any entries in
> my Pharmcas table, it's worked before, last spring when we used it
> last, but right now it's not working? It uploads and saves the file as
> it should, but then doesn't do any of the creating of entries in the
> table?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
Hi all - i've got a mysterious problem with my admin templates and I
think its a version problem but can't figure it out.

The contrib.admin templates seem to be throwing some very crazy
TemplateSyntaxError(s) in many of the admin templates when i moved my
app to my production environment.  I'm thinking this must be some kind
of version problem so I removed django completely and reinstalled the
production version and still have the same problems.  Now, the same
exact project works perfectly on my development server, but the
service[debian/lighttpd/fcgi] that I set up for production displays
these issues - oddly enough when I first installed it, before taking
the project live, it seemed to work.  I'm using the exact same path to
template loaders in production/dev.

Anyone have any ideas what's going on?  Has anyone else experienced
this problem?

Here are 2 examples of errors being thrown:
---

TemplateSyntaxError at /admin/
In template /usr/lib/python2.5/site-packages/django/contrib/admin/
templates/admin/base.html, error at line 31
Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
21  
22  
23  
24  {% block branding %}{% endblock %}
25  
26  {% if user.is_active and user.is_staff %}
27  
28  {% trans 'Welcome,' %}
29  {% filter force_escape %}{% firstof
user.first_name user.username %}{% endfilter %}.
30  {% block userlinks %}
31  {% url django-admindocs-docroot as docsroot %}
32  {% if docsroot %}
33  {% trans
'Documentation' %} /
34  {% endif %}
35  {% url admin:password_change as password_change_url
%}
36  {% if password_change_url %}
37  

and

TemplateSyntaxError at /admin/auth/group/add/
In template /usr/lib/python2.5/site-packages/django/contrib/admin/
templates/admin/includes/fieldset.html, error at line 18
Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
8   {{ line.errors }}
9   {% for field in line %}
10  
11  {% if field.is_checkbox %}
12  {{ field.field }}{{ field.label_tag }}
13  {% else %}
14  {{ field.label_tag }}
15  {% if field.is_readonly %}
16  {{ field.contents }}
17  {% else %}
18  {{ field.field }}
19  {% endif %}
20  {% endif %}

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



Calling method of a proxy-model in a template

2010-09-30 Thread mettwoch
Hi,

Let's say that I have a proxy model of the User model that adds some
methods. What would be an elegant way to access these methods from
within a template in the same easy way I access the User attributes
through {{ request.session.user.some_attribute }}.

Kindly Yours
Marc

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



Re: DjangoCon 2011

2010-09-30 Thread sserrano
I live in Argentina, If I wanted to go to the DjangoCon in Portland,
it would require a Bus to Buenos Aires, then take an international
flight to a US mayor city and then another to reach Portland, overall
I would be travelling more nearly an entire day to reach the
conference.

New York, San Francisco, Los Angeles and Washington have direct
flights from almost every country. I'm sure if the conference is place
in a city with easy access it would have more people going.

Cheers, Sebastian

On Sep 29, 3:20 pm, Siraaj Khandkar  wrote:
> On Sep 27, 10:51 pm, Steve Holden  wrote:
>
> >
> > Sadly, New York is out for2011. Those (very few) venues whose costs are
> > low enough are already booked up. Those with space are *much* too
> > expensive. If we want to look at a New YorkDjangoConUS we should
> > probably plan at least two years ahead, and still expect it to be quite
> > a lot more expensive than Portland (even without factoring in the higher
> > cost of eating out and so on in New York).
>
> Look into Cooper Union in New York. NYCBUG is holding NYCBSDCon there
> in a little over a month, with reasonable costs.
>
> http://www.nycbsdcon.org/2010/
>
> ...
>
>
>
> > We are currently waiting for replies from one or two more hotels more
> > "in the thick of things" in the DC area. This would probably mean a bit
> > more difficulty getting to the venue from the airports, but it would
> > mean that Djangonauts who want to venture out from the hotel would find
> > more facilities close by.
>
> DC sounds cool, UPenn in Philadelphia would be a good place to
> consider as well.

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



url not going to view

2010-09-30 Thread Bradley Hintze
Hi,

I have made a successful Django app in the past. and decided to start
a new one. Except I'm running into a problem. I started a new project
to isolate the problem but still am having a problem. Here it is:

I have a link to a different page from 'home' called 'here'. When I
click the link I get the right URL but get the home.html view rather
than the expected here.html view. Here are the relevant code.

#url.py
from django.conf.urls.defaults import *
from MolProbity_View.views import *
from django.conf import settings

urlpatterns = patterns('',
(r'^', home_view),
(r'^here/', here),
# Example:
)

#views.py
from django.shortcuts import render_to_response, HttpResponseRedirect
from django.http import HttpResponse
from django.template import Context, Template, RequestContext
from django.views.decorators.csrf import csrf_protect
import os

def home_view(request):
c = {'we_r_home':'yes'}
return render_to_response('home.html', c,
context_instance=RequestContext(request))

def here(request):
c = {'we_r_home':'no'}
return render_to_response('here.html', c,
context_instance=RequestContext(request))

#home.html


home


Hello
{{ we_r_home }}
Link



#here


here


Good Bye
{{ we_r_home }}



I think I'm not seeing something obvious. Any ideas?
Thanks
-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Re: url not going to view

2010-09-30 Thread Carlton Gibson

On 30 Sep 2010, at 15:42, Bradley Hintze wrote:

> urlpatterns = patterns('',
>(r'^', home_view),
>(r'^here/', here),
># Example:
> )

your first pattern matches all URLs which have a beginning, which is all URLs. 
You need to add the $s at the end:

urlpatterns = patterns('',
   (r'^$', home_view),
   (r'^here/$', here),
   # Example:
)

HTH

Regards,
Carlton

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread mhall119
I've recently open-sourced some code that I developed for my work
projects that may do at least part of what you need:
http://bitbucket.org/mhall119/django-extauth/wiki/Home

The basic idea is that you define a "role" that is a relationship
between a user and an instance of a given Model.  With your example,
you would created an "owner" role for your model, that somehow links
the user instance to the model instance.  Usually you do this directly
via a ForeignKey in your model, but they can be as complex as you want
them to be.

On Sep 30, 9:50 am, Miguel Araujo  wrote:
>  Hi everyone,
>
> I have been recently thinking about an object permission system. After
> reviewing Florian Apolloner (apollo13) patch for ticket
> #11010 and
> reading his article at Django
> Advent.
> I though about creating an Object Permission Rule Backend. The purpose of
> this message is explain you my idea, so I can receive feedback from Django
> users and developers. This way I would like to discern if it's worth coding
> it or if it's a good approach to a reusable solution.
>
> I will reuse apollo's code to elaborate my idea. My Backend would look
> similar to:
>
> class ObjectPermBackend(object):
>     supports_object_permissions = True
>     supports_anonymous_user = True
>
>     def authenticate(self, username, password):
>         return None
>
>     def has_perm(self, user_obj, perm, obj=None):
>         if not user_obj.is_authenticated():
>             user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
>
>         if obj is None:
>             return False
>
>         ct = ContentType.objects.get_for_model(obj)
>
>         try:
>             perm = perm.split('.')[-1].split('_')[0]
>         except IndexError:
>             return False
>
> # Simplified rule system
>         # Of course objects should extend an interface
> if (perm == "ownage")
> return obj.is_owned_by(user_obj)
>
> elif (perm == "edit")
> return obj.can_be_edited_by(user_obj)
>
> # Here be Dragons
>
> As I love decorators, I would like to create a permission_required decorator
> that accepted more than a parameter, so:
>
> @permission_required('app.code_name') would
> become @permission_required('app.code_name', FLAG)
>
> If the FLAG is set the decorator searches in the model associated to the
> content type of the permission, for the name of the field for the PK. For
> the example imagine idArticle. Now it instantiates an object of that model
> with Model.objects.get(pk=request.idArticle). So it would be necessary to
> match request parameters to model fileds (This is the best idea I've come up
> with). Once it has the right object, it passes it to the backend for
> permission checks.
>
> I know I could do a decorator like @own_article but I'm looking for a more
> reusable solution, that I would make open source and release at Github.
>
> What do you think? Is it feasible and well laid out?
>
> Thanks, best regards
> Miguel Araujo

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



Re: template syntax errors in production admin site (version problem?)

2010-09-30 Thread Steve Holden
On 9/30/2010 9:50 AM, bobbymanuel wrote:
> Hi all - i've got a mysterious problem with my admin templates and I
> think its a version problem but can't figure it out.
> 
> The contrib.admin templates seem to be throwing some very crazy
> TemplateSyntaxError(s) in many of the admin templates when i moved my
> app to my production environment.  I'm thinking this must be some kind
> of version problem so I removed django completely and reinstalled the
> production version and still have the same problems.  Now, the same
> exact project works perfectly on my development server, but the
> service[debian/lighttpd/fcgi] that I set up for production displays
> these issues - oddly enough when I first installed it, before taking
> the project live, it seemed to work.  I'm using the exact same path to
> template loaders in production/dev.
> 
> Anyone have any ideas what's going on?  Has anyone else experienced
> this problem?
> 
> Here are 2 examples of errors being thrown:
> ---
> 
> TemplateSyntaxError at /admin/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/base.html, error at line 31
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 21
> 22
> 23
> 24{% block branding %}{% endblock %}
> 25
> 26{% if user.is_active and user.is_staff %}
> 27
> 28{% trans 'Welcome,' %}
> 29{% filter force_escape %}{% firstof
> user.first_name user.username %}{% endfilter %}.
> 30{% block userlinks %}
> 31{% url django-admindocs-docroot as docsroot %}
> 32{% if docsroot %}
> 33{% trans
> 'Documentation' %} /
> 34{% endif %}
> 35{% url admin:password_change as password_change_url
> %}
> 36{% if password_change_url %}
> 37
> 
> and
> 
> TemplateSyntaxError at /admin/auth/group/add/
> In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> templates/admin/includes/fieldset.html, error at line 18
> Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> 8 {{ line.errors }}
> 9 {% for field in line %}
> 10 class="field-box"{% endif %}>
> 11{% if field.is_checkbox %}
> 12{{ field.field }}{{ field.label_tag }}
> 13{% else %}
> 14{{ field.label_tag }}
> 15{% if field.is_readonly %}
> 16{{ field.contents }}
> 17{% else %}
> 18{{ field.field }}
> 19{% endif %}
> 20{% endif %}
> 

Is there any possibility that your server is trying to report a 500
error, and that it's actually the 500 template it's complaining about?

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

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



Re: url not going to view

2010-09-30 Thread Bradley Hintze
Why $s, if you don't mind me asking?

On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
 wrote:
>
> On 30 Sep 2010, at 15:42, Bradley Hintze wrote:
>
>> urlpatterns = patterns('',
>>    (r'^', home_view),
>>    (r'^here/', here),
>>    # Example:
>> )
>
> your first pattern matches all URLs which have a beginning, which is all 
> URLs. You need to add the $s at the end:
>
> urlpatterns = patterns('',
>   (r'^$', home_view),
>   (r'^here/$', here),
>   # Example:
> )
>
> HTH
>
> Regards,
> Carlton
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Re: url not going to view

2010-09-30 Thread Carlton Gibson
Its the plural of $.

On 30 Sep 2010, at 16:02, Bradley Hintze wrote:

> Why $s, if you don't mind me asking?
> 
> On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
>  wrote:
>> 
>> On 30 Sep 2010, at 15:42, Bradley Hintze wrote:
>> 
>>> urlpatterns = patterns('',
>>>(r'^', home_view),
>>>(r'^here/', here),
>>># Example:
>>> )
>> 
>> your first pattern matches all URLs which have a beginning, which is all 
>> URLs. You need to add the $s at the end:
>> 
>> urlpatterns = patterns('',
>>   (r'^$', home_view),
>>   (r'^here/$', here),
>>   # Example:
>> )
>> 
>> HTH
>> 
>> Regards,
>> Carlton
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>> 
>> 
> 
> 
> 
> -- 
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Calling method of a proxy-model in a template

2010-09-30 Thread Daniel Roseman
On Sep 30, 3:31 pm, mettwoch  wrote:
> Hi,
>
> Let's say that I have a proxy model of the User model that adds some
> methods. What would be an elegant way to access these methods from
> within a template in the same easy way I access the User attributes
> through {{ request.session.user.some_attribute }}.
>
> Kindly Yours
> Marc

Well, you don't access the user through request.session.user, but
simply through request.user. And if you have the auth context
processor installed, which you do by default, you can simply get it
via {{ user }}.

So one answer is to define your own context processor to use in place
of the auth one, which returns an instance of your proxy class for the
user.

Another possibility is to provide a custom request middleware which
replaces request.user with your version. This might be preferable, as
you now have access to the extra methods throughout your code, not
just in templates.
--
DR.

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



Re: url not going to view

2010-09-30 Thread Bradley Hintze
LOL, let me rephrase.

What is the significance of the '$' (or what does it mean) in the URLs
as pointed out in previous messages?

On Thu, Sep 30, 2010 at 11:15 AM, Carlton Gibson
 wrote:
> Its the plural of $.
>
> On 30 Sep 2010, at 16:02, Bradley Hintze wrote:
>
>> Why $s, if you don't mind me asking?
>>
>> On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
>>  wrote:
>>>
>>> On 30 Sep 2010, at 15:42, Bradley Hintze wrote:
>>>
 urlpatterns = patterns('',
    (r'^', home_view),
    (r'^here/', here),
    # Example:
 )
>>>
>>> your first pattern matches all URLs which have a beginning, which is all 
>>> URLs. You need to add the $s at the end:
>>>
>>> urlpatterns = patterns('',
>>>   (r'^$', home_view),
>>>   (r'^here/$', here),
>>>   # Example:
>>> )
>>>
>>> HTH
>>>
>>> Regards,
>>> Carlton
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>>
>>
>> --
>> Bradley J. Hintze
>> Graduate Student
>> Duke University
>> School of Medicine
>> 801-712-8799
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Re: url not going to view

2010-09-30 Thread Steve Holden
Just as "^" means "start of string" so "$" mean "end of string", so "^$"
means a string where the end is next to the beginning.

You can read the Python documentation for the "re"module for more
insight into all this.

regards
 Steve

On 9/30/2010 11:20 AM, Bradley Hintze wrote:
> LOL, let me rephrase.
> 
> What is the significance of the '$' (or what does it mean) in the URLs
> as pointed out in previous messages?
> 
> On Thu, Sep 30, 2010 at 11:15 AM, Carlton Gibson
>  wrote:
>> Its the plural of $.
>>
>> On 30 Sep 2010, at 16:02, Bradley Hintze wrote:
>>
>>> Why $s, if you don't mind me asking?
>>>
>>> On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
>>>  wrote:

 On 30 Sep 2010, at 15:42, Bradley Hintze wrote:

> urlpatterns = patterns('',
>(r'^', home_view),
>(r'^here/', here),
># Example:
> )

 your first pattern matches all URLs which have a beginning, which is all 
 URLs. You need to add the $s at the end:

 urlpatterns = patterns('',
   (r'^$', home_view),
   (r'^here/$', here),
   # Example:
 )

 HTH

 Regards,
 Carlton

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


>>>
>>>
>>>
>>> --
>>> Bradley J. Hintze
>>> Graduate Student
>>> Duke University
>>> School of Medicine
>>> 801-712-8799
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> 
> 
> 


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

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



Re: template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
interesting idea - but unfortunately, not it.

i actually made a copy of admin.contrib.templates and fixed the syntax
that its complaining about, and it starts working.
it doesn't like the following syntax :  {% url name1 as name2 %}  -
found in 6 places in admin.contrib.templates
it also doesn't like {{ field.field }}  - found all over the place ;)
if i remove those lines, ... presto magic... it works! ;(

also - tested it with manage.py runserver and it produces the same
errors.

i'm wondering if it could have anything to do with 1: Windows EOL
characters in my settings file. or 2: latin character encoding in
MySql
pretty much grasping at straws now.

let me know if you think of anything else.

Thx,
B


On Sep 30, 11:05 am, Steve Holden  wrote:
> On 9/30/2010 9:50 AM, bobbymanuel wrote:
>
>
>
>
>
> > Hi all - i've got a mysterious problem with my admin templates and I
> > think its a version problem but can't figure it out.
>
> > The contrib.admin templates seem to be throwing some very crazy
> > TemplateSyntaxError(s) in many of the admin templates when i moved my
> > app to my production environment.  I'm thinking this must be some kind
> > of version problem so I removed django completely and reinstalled the
> > production version and still have the same problems.  Now, the same
> > exact project works perfectly on my development server, but the
> > service[debian/lighttpd/fcgi] that I set up for production displays
> > these issues - oddly enough when I first installed it, before taking
> > the project live, it seemed to work.  I'm using the exact same path to
> > template loaders in production/dev.
>
> > Anyone have any ideas what's going on?  Has anyone else experienced
> > this problem?
>
> > Here are 2 examples of errors being thrown:
> > ---
>
> > TemplateSyntaxError at /admin/
> > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > templates/admin/base.html, error at line 31
> > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > 21     
> > 22     
> > 23         
> > 24         {% block branding %}{% endblock %}
> > 25         
> > 26         {% if user.is_active and user.is_staff %}
> > 27         
> > 28             {% trans 'Welcome,' %}
> > 29             {% filter force_escape %}{% firstof
> > user.first_name user.username %}{% endfilter %}.
> > 30             {% block userlinks %}
> > 31                 {% url django-admindocs-docroot as docsroot %}
> > 32                 {% if docsroot %}
> > 33                     {% trans
> > 'Documentation' %} /
> > 34                 {% endif %}
> > 35                 {% url admin:password_change as password_change_url
> > %}
> > 36                 {% if password_change_url %}
> > 37                     
>
> > and
>
> > TemplateSyntaxError at /admin/auth/group/add/
> > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > templates/admin/includes/fieldset.html, error at line 18
> > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > 8              {{ line.errors }}
> > 9              {% for field in line %}
> > 10                  > class="field-box"{% endif %}>
> > 11                     {% if field.is_checkbox %}
> > 12                         {{ field.field }}{{ field.label_tag }}
> > 13                     {% else %}
> > 14                         {{ field.label_tag }}
> > 15                         {% if field.is_readonly %}
> > 16                             {{ field.contents }}
> > 17                         {% else %}
> > 18                             {{ field.field }}
> > 19                         {% endif %}
> > 20                     {% endif %}
>
> Is there any possibility that your server is trying to report a 500
> error, and that it's actually the 500 template it's complaining about?
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

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



Re: DjangoCon 2011

2010-09-30 Thread Steve Holden
On 9/30/2010 10:36 AM, sserrano wrote:
>> I live in Argentina, If I wanted to go to the DjangoCon in
>> Portland, it would require a Bus to Buenos Aires, then take an
>> international flight to a US mayor city and then another to reach
>> Portland, overall I would be travelling more nearly an entire day
>> to reach the conference.
>> 
>> New York, San Francisco, Los Angeles and Washington have direct 
>> flights from almost every country. I'm sure if the conference is
>> place in a city with easy access it would have more people going.
>> 
Thank you for your input. What you say is true. Unfortunately (for
people in your position) growth in numbers isn't a primary goal for
DjangoCon US and Portland seems to attract sufficient delegates to make
it successful.

I am not unmindful of these factors, but on the other side of the coin
it's likely (for precisely the convenience reasons you state) that those
locations with convenient international airports will have hotels that
are significantly more expensive than places like Portland.

Cost *is* a major inhibitor of attendance, and unless the Django
community advise otherwise a high priority will be trying to keep the
2011 cost as close to this year's level as I can.

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

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



Re: url not going to view

2010-09-30 Thread Carlton Gibson
Django: The Definitive Guide gives a good tutorial/refresher too:

http://djangobook.com/en/2.0/chapter03/


On 30 Sep 2010, at 16:25, Steve Holden wrote:

> Just as "^" means "start of string" so "$" mean "end of string", so "^$"
> means a string where the end is next to the beginning.
> 
> You can read the Python documentation for the "re"module for more
> insight into all this.
> 
> regards
> Steve
> 
> On 9/30/2010 11:20 AM, Bradley Hintze wrote:
>> LOL, let me rephrase.
>> 
>> What is the significance of the '$' (or what does it mean) in the URLs
>> as pointed out in previous messages?
>> 
>> On Thu, Sep 30, 2010 at 11:15 AM, Carlton Gibson
>>  wrote:
>>> Its the plural of $.
>>> 
>>> On 30 Sep 2010, at 16:02, Bradley Hintze wrote:
>>> 
 Why $s, if you don't mind me asking?
 
 On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
  wrote:
> 
> On 30 Sep 2010, at 15:42, Bradley Hintze wrote:
> 
>> urlpatterns = patterns('',
>>   (r'^', home_view),
>>   (r'^here/', here),
>>   # Example:
>> )
> 
> your first pattern matches all URLs which have a beginning, which is all 
> URLs. You need to add the $s at the end:
> 
> urlpatterns = patterns('',
>  (r'^$', home_view),
>  (r'^here/$', here),
>  # Example:
> )
> 
> HTH
> 
> Regards,
> Carlton
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
 
 
 
 --
 Bradley J. Hintze
 Graduate Student
 Duke University
 School of Medicine
 801-712-8799
 
 --
 You received this message because you are subscribed to the Google Groups 
 "Django users" group.
 To post to this group, send email to django-us...@googlegroups.com.
 To unsubscribe from this group, send email to 
 django-users+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/django-users?hl=en.
 
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>> 
>>> 
>> 
>> 
>> 
> 
> 
> -- 
> DjangoCon US 2010 September 7-9 http://djangocon.us/
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Full Text Search

2010-09-30 Thread Alessandro Ronchi
Is there any way to make a FULL TEXT search not in BOOLEAN MODE?
I've found only
http://docs.djangoproject.com/en/1.1/ref/models/querysets/#search

It says it uses BOOLEAN MODE as a default, but doesn't tell how to
avoid default...


-- 
Alessandro Ronchi
http://www.soasi.com

Hobby & Giochi
http://hobbygiochi.com
http://www.facebook.com/hobbygiochi

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



Re: url not going to view

2010-09-30 Thread Bradley Hintze
OH, they're regular expressions, right? Ok, I need to try to
understand RE but they still escape any meaning for me somehow.

On Thu, Sep 30, 2010 at 11:33 AM, Carlton Gibson
 wrote:
> Django: The Definitive Guide gives a good tutorial/refresher too:
>
> http://djangobook.com/en/2.0/chapter03/
>
>
> On 30 Sep 2010, at 16:25, Steve Holden wrote:
>
>> Just as "^" means "start of string" so "$" mean "end of string", so "^$"
>> means a string where the end is next to the beginning.
>>
>> You can read the Python documentation for the "re"module for more
>> insight into all this.
>>
>> regards
>> Steve
>>
>> On 9/30/2010 11:20 AM, Bradley Hintze wrote:
>>> LOL, let me rephrase.
>>>
>>> What is the significance of the '$' (or what does it mean) in the URLs
>>> as pointed out in previous messages?
>>>
>>> On Thu, Sep 30, 2010 at 11:15 AM, Carlton Gibson
>>>  wrote:
 Its the plural of $.

 On 30 Sep 2010, at 16:02, Bradley Hintze wrote:

> Why $s, if you don't mind me asking?
>
> On Thu, Sep 30, 2010 at 10:55 AM, Carlton Gibson
>  wrote:
>>
>> On 30 Sep 2010, at 15:42, Bradley Hintze wrote:
>>
>>> urlpatterns = patterns('',
>>>   (r'^', home_view),
>>>   (r'^here/', here),
>>>   # Example:
>>> )
>>
>> your first pattern matches all URLs which have a beginning, which is all 
>> URLs. You need to add the $s at the end:
>>
>> urlpatterns = patterns('',
>>  (r'^$', home_view),
>>  (r'^here/$', here),
>>  # Example:
>> )
>>
>> HTH
>>
>> Regards,
>> Carlton
>>
>> --
>> You received this message because you are subscribed to the Google 
>> Groups "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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


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



-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799

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



Directing User to specific page after login

2010-09-30 Thread octopusgrabbus
I am looking for either programming samples or specific documentation
that show how a user is redirected to a page specific to that user,
after login. Given I am just starting out with Django, if this is
really advanced, then I'll settle for getting people logged in and
give them the same page.

Thanks.

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



Why Django Admin Won't Display full graphics

2010-09-30 Thread octopusgrabbus
When I run Django admin with runserver running, I get nice graphics. I
don't when I run Django admin from apache. I can log into my django
application from apache, but do not get the graphics. I'm looking for
examples or documentation on how to fix this.

Thanks.
cmn

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



Re: Why Django Admin Won't Display full graphics

2010-09-30 Thread Addy Yeow
runserver takes care of thing like this for you but you need to handle
it properly in Apache.
See 
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-the-admin-files

On Fri, Oct 1, 2010 at 12:03 AM, octopusgrabbus
 wrote:
>
> When I run Django admin with runserver running, I get nice graphics. I
> don't when I run Django admin from apache. I can log into my django
> application from apache, but do not get the graphics. I'm looking for
> examples or documentation on how to fix this.
>
> Thanks.
> cmn
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Why Django Admin Won't Display full graphics

2010-09-30 Thread Alec Shaner
Also, if you're using mod_wsgi (recommended over mod_python), see this:

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango


On Thu, Sep 30, 2010 at 12:12 PM, Addy Yeow  wrote:
> runserver takes care of thing like this for you but you need to handle
> it properly in Apache.
> See 
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-the-admin-files
>
> On Fri, Oct 1, 2010 at 12:03 AM, octopusgrabbus
>  wrote:
>>
>> When I run Django admin with runserver running, I get nice graphics. I
>> don't when I run Django admin from apache. I can log into my django
>> application from apache, but do not get the graphics. I'm looking for
>> examples or documentation on how to fix this.
>>
>> Thanks.
>> cmn
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: template syntax errors in production admin site (version problem?)

2010-09-30 Thread bobbymanuel
PROBLEM SOLVED:  upgrade to Python 2.7 on server resolved issue.
Apparrently Django 1.2.3 is not fully compatible with Python 2.5

On Sep 30, 11:28 am, bobbymanuel  wrote:
> interesting idea - but unfortunately, not it.
>
> i actually made a copy of admin.contrib.templates and fixed the syntax
> that its complaining about, and it starts working.
> it doesn't like the following syntax :  {% url name1 as name2 %}  -
> found in 6 places in admin.contrib.templates
> it also doesn't like {{ field.field }}  - found all over the place ;)
> if i remove those lines, ... presto magic... it works! ;(
>
> also - tested it with manage.py runserver and it produces the same
> errors.
>
> i'm wondering if it could have anything to do with 1: Windows EOL
> characters in my settings file. or 2: latin character encoding in
> MySql
> pretty much grasping at straws now.
>
> let me know if you think of anything else.
>
> Thx,
> B
>
> On Sep 30, 11:05 am, Steve Holden  wrote:
>
>
>
> > On 9/30/2010 9:50 AM, bobbymanuel wrote:
>
> > > Hi all - i've got a mysterious problem with my admin templates and I
> > > think its a version problem but can't figure it out.
>
> > > The contrib.admin templates seem to be throwing some very crazy
> > > TemplateSyntaxError(s) in many of the admin templates when i moved my
> > > app to my production environment.  I'm thinking this must be some kind
> > > of version problem so I removed django completely and reinstalled the
> > > production version and still have the same problems.  Now, the same
> > > exact project works perfectly on my development server, but the
> > > service[debian/lighttpd/fcgi] that I set up for production displays
> > > these issues - oddly enough when I first installed it, before taking
> > > the project live, it seemed to work.  I'm using the exact same path to
> > > template loaders in production/dev.
>
> > > Anyone have any ideas what's going on?  Has anyone else experienced
> > > this problem?
>
> > > Here are 2 examples of errors being thrown:
> > > ---
>
> > > TemplateSyntaxError at /admin/
> > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > > templates/admin/base.html, error at line 31
> > > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > > 21     
> > > 22     
> > > 23         
> > > 24         {% block branding %}{% endblock %}
> > > 25         
> > > 26         {% if user.is_active and user.is_staff %}
> > > 27         
> > > 28             {% trans 'Welcome,' %}
> > > 29             {% filter force_escape %}{% firstof
> > > user.first_name user.username %}{% endfilter %}.
> > > 30             {% block userlinks %}
> > > 31                 {% url django-admindocs-docroot as docsroot %}
> > > 32                 {% if docsroot %}
> > > 33                     {% trans
> > > 'Documentation' %} /
> > > 34                 {% endif %}
> > > 35                 {% url admin:password_change as password_change_url
> > > %}
> > > 36                 {% if password_change_url %}
> > > 37                     
>
> > > and
>
> > > TemplateSyntaxError at /admin/auth/group/add/
> > > In template /usr/lib/python2.5/site-packages/django/contrib/admin/
> > > templates/admin/includes/fieldset.html, error at line 18
> > > Caught SyntaxError while rendering: invalid syntax (views.py, line 52)
> > > 8              {{ line.errors }}
> > > 9              {% for field in line %}
> > > 10                  > > class="field-box"{% endif %}>
> > > 11                     {% if field.is_checkbox %}
> > > 12                         {{ field.field }}{{ field.label_tag }}
> > > 13                     {% else %}
> > > 14                         {{ field.label_tag }}
> > > 15                         {% if field.is_readonly %}
> > > 16                             {{ field.contents }}
> > > 17                         {% else %}
> > > 18                             {{ field.field }}
> > > 19                         {% endif %}
> > > 20                     {% endif %}
>
> > Is there any possibility that your server is trying to report a 500
> > error, and that it's actually the 500 template it's complaining about?
>
> > regards
> >  Steve
> > --
> > DjangoCon US 2010 September 7-9http://djangocon.us/

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
I wanted to write this post anyway, gives a quick solution to upload
files above the public directory and serve the files with django-
filetransfers. Hopefully it will be easier to find from search
engines.

http://nemesisdesign.net/blog/coding/django-private-file-upload-and-serving/




On Sep 30, 10:40 am, Xavier Ordoquy  wrote:
> Hi,
>
> To me, it looks like the documentation already gave the answer.
>
> Regards,
> Xavier.
>
> Le 30 sept. 2010 à 10:37, Federico Capoano a écrit :
>
>
>
> > PS: i'll post a solution so other noobs like me will see how to do
> > that..
>
> > On 30 Set, 10:35, Federico Capoano  wrote:
> >> Yes you're right, I'm trying it out. I'll post a solution when I'm
> >> done.
>
> >> On 30 Set, 10:10, Xavier Ordoquy  wrote:
>
> >>> Well, the documentation already tells you about 
> >>> it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> >>> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
>  Is this not possible? I wonder why Django force to upload files only
>  in a certain directory and doesn't allow more flexibility.
>
>  On 29 Set, 19:46, Federico Capoano  wrote:
> > Hi everyone,
>
> > is it possible to write a custom model filefield that upload files
> > somewhere above the public directory?
>
>  --
>  You received this message because you are subscribed to the Google 
>  Groups "Django users" group.
>  To post to this group, send email to django-us...@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-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: UnicodeEncodeError

2010-09-30 Thread jean polo
ok, thanks to everybody for the help but unfortunately nothing works
for my issue.
(except Karen one that solves it on one of my local machines but not
the other which has the same linux system... weird..).

I guess I'll ask my client to rename their files without any special
char
not the best solution but a good habit anyway =)

cheers,
_y


On Sep 30, 2:20 pm, Karen Tracey  wrote:
> On Wed, Sep 29, 2010 at 12:59 PM, jean polo wrote:
>
>
>
> > Hi.
> > I get an 'UnicodeEncodeError' if I upload a file (ImageField) with non-
> > ascii chars in my application (django-1.2.1).
>
> > I added:
>
> > export LANG='en_US.UTF-8'
> > export LC_ALL='en_US.UTF-8'
>
> > in my /etc/apache2/envvars as stated here:
>
> >http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>
> > but I still have the same error (after restarting apache).
> > Any hint much appreciated.
>
> Some servers do not have the necessary language files to allow successfully
> setting the locale to one that supports utf-8 encoding. See the very last
> sentence here:http://code.djangoproject.com/wiki/ExpectedTestFailures
>
> You should be able to experiment with setting these variables in a shell
> session and passing unicode strings containing non-ASCII characters to file
> system routines like stat. If it works in a shell, then likely you've got
> the necessary language support installed, and the problem then is that the
> Apache configuration for some reason is not taking effect. If you cannot get
> it to work in a shell either, then likely you are missing a language pack
> that would allow successfully setting locale in this way.
>
> Karen
> --http://tracey.org/kmt/

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



Re: Directing User to specific page after login

2010-09-30 Thread Jurgen Blignaut
I am assuming that you already have an URL in mind that you want to redirect
to after login. To automatically go to that URL, simply put this setting in
your "settings.py" file:

LOGIN_REDIRECT_URL = '/the_url_you_want/to_redirect_to/'

Upon login, the member will automagically end up at that URL. In the view
for that page, you should be able to get hold of the logged in member using
this:

user = request.user

and then customise your response for that specific user. Hope that helps.

On 30 September 2010 17:59, octopusgrabbus wrote:

> I am looking for either programming samples or specific documentation
> that show how a user is redirected to a page specific to that user,
> after login. Given I am just starting out with Django, if this is
> really advanced, then I'll settle for getting people logged in and
> give them the same page.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Jurgen Blignaut
Software Engineer with Python
Webtide cc
http://www.webtide.co.za
jur...@webtide.co.za
+27829227239

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



contrib-admin in a multiuser environment is a bit scary

2010-09-30 Thread AndyB
I've been having bad dreams about the ways in which contrib-admin can
eat your data when you have more than one administrator.

As a worst-case scenario imagine a model with some list_editable
fields:

Admin1 has the changelist open for a considerable length of time
Admin2 makes a load of changes
Admin1 makes one change and wipes all of Admin2's changes (at least
for the number of items specified in ModelAdmin.list_per_page which is
100 by default)

How do other people handle these issues? This must have bitten someone
severely by now?

There isn't much in Trac about this. I found:
http://code.djangoproject.com/ticket/11652
http://code.djangoproject.com/ticket/11313

At the very least there should be giant warnings in letters of flame
in the admin docs.

Has anyone looked into:

a) Optimistic locking for changelist and change forms
b) modifying list_editable to only save the instances that have
changed

or anything similar?

Andy

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



PgWest Talk descriptions are up

2010-09-30 Thread Joshua D. Drake
Hello,

The talk descriptions for PostgreSQL Conference West 2010 are up,
including a healthy dose of Django content.

https://www.postgresqlconference.org/2010/west/talks

JD
-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

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



Re: Directing User to specific page after login

2010-09-30 Thread Huy Ton That
I was going to mention passing a next variable, but Jurgen responded with a
cleaner global solution (:

Learn something new every day.


On Thu, Sep 30, 2010 at 11:59 AM, octopusgrabbus
wrote:

> I am looking for either programming samples or specific documentation
> that show how a user is redirected to a page specific to that user,
> after login. Given I am just starting out with Django, if this is
> really advanced, then I'll settle for getting people logged in and
> give them the same page.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Unable to login to admin site in localhost

2010-09-30 Thread mamcx
As reported on :http://stackoverflow.com/questions/3817808/unable-to-
login-to-admin-site-in-localhost

I can't login to the admin site on localhost.

I try with firefox, IE.

I try using the 127.0.0.1:8000 address. Also, I set the
SESSION_COOKIE_DOMAIN to localhost, localhost:8000

I change the host file to:

127.0.0.1   test.com
and set:

SESSION_COOKIE_DOMAIN = 'test.com'

I can login in production (only after the SESSION_COOKIE_DOMAIN
configuration).

I'm using django rev 1.0.1. I can't upgrade to last trunk. The best,
is move to 1.0.2 (I use byteflow and multilingual, and not work with
new trunk)

I try adding to the host file my public domain, and not works (ie:
127.0.0.1 www.mysite.com).

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



Change auth User display name in admin interface

2010-09-30 Thread Nathan
I'm using the django User authentication.

I have a model that has a ManyToManyField which allows you to select
several users to associate with that model. In the django admin site,
it's set to use the filter_horizontal option.

When adding a new instance of the model through the admin interface,
it shows you the username of the User. I would like it to show the
first_name and last_name instead. I tried using a Proxy Model and
changing the __unicode__(self) with no success, it still shows the
username in the admin site. I also tried inheriting from the User
class, but it did not work either and I would rather not do it that
way.

I'm a relative noob at django, so I could very easily be missing
something simple. Any suggestions?

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread Miguel Araujo
Hi Michael,

I have been looking at your project, django.extauth and I have to say I
really like its architecture and permission handling. I have to say that my
rule system is kind of the same thing of your role system, except mine is
less flexible. I'm going to look a little bit the code, install it and see
if I can help you with anything.

Only thing that cached my eye is that code is Copyrighted. Why not using an
Open-source license?

Thanks for your mail, regards
Miguel Araujo

2010/9/30 mhall119 

> I've recently open-sourced some code that I developed for my work
> projects that may do at least part of what you need:
> http://bitbucket.org/mhall119/django-extauth/wiki/Home
>
> The basic idea is that you define a "role" that is a relationship
> between a user and an instance of a given Model.  With your example,
> you would created an "owner" role for your model, that somehow links
> the user instance to the model instance.  Usually you do this directly
> via a ForeignKey in your model, but they can be as complex as you want
> them to be.
>
> On Sep 30, 9:50 am, Miguel Araujo  wrote:
> >  Hi everyone,
> >
> > I have been recently thinking about an object permission system. After
> > reviewing Florian Apolloner (apollo13) patch for ticket
> > #11010 and
> > reading his article at Django
> > Advent.
> > I though about creating an Object Permission Rule Backend. The purpose of
> > this message is explain you my idea, so I can receive feedback from
> Django
> > users and developers. This way I would like to discern if it's worth
> coding
> > it or if it's a good approach to a reusable solution.
> >
> > I will reuse apollo's code to elaborate my idea. My Backend would look
> > similar to:
> >
> > class ObjectPermBackend(object):
> > supports_object_permissions = True
> > supports_anonymous_user = True
> >
> > def authenticate(self, username, password):
> > return None
> >
> > def has_perm(self, user_obj, perm, obj=None):
> > if not user_obj.is_authenticated():
> > user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
> >
> > if obj is None:
> > return False
> >
> > ct = ContentType.objects.get_for_model(obj)
> >
> > try:
> > perm = perm.split('.')[-1].split('_')[0]
> > except IndexError:
> > return False
> >
> > # Simplified rule system
> > # Of course objects should extend an interface
> > if (perm == "ownage")
> > return obj.is_owned_by(user_obj)
> >
> > elif (perm == "edit")
> > return obj.can_be_edited_by(user_obj)
> >
> > # Here be Dragons
> >
> > As I love decorators, I would like to create a permission_required
> decorator
> > that accepted more than a parameter, so:
> >
> > @permission_required('app.code_name') would
> > become @permission_required('app.code_name', FLAG)
> >
> > If the FLAG is set the decorator searches in the model associated to the
> > content type of the permission, for the name of the field for the PK. For
> > the example imagine idArticle. Now it instantiates an object of that
> model
> > with Model.objects.get(pk=request.idArticle). So it would be necessary to
> > match request parameters to model fileds (This is the best idea I've come
> up
> > with). Once it has the right object, it passes it to the backend for
> > permission checks.
> >
> > I know I could do a decorator like @own_article but I'm looking for a
> more
> > reusable solution, that I would make open source and release at Github.
> >
> > What do you think? Is it feasible and well laid out?
> >
> > Thanks, best regards
> > Miguel Araujo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread mhall119
The license is a 3-clause BSD style license, it's compatible with
Django's license as far as I know.

On Sep 30, 1:55 pm, Miguel Araujo  wrote:
> Hi Michael,
>
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that my
> rule system is kind of the same thing of your role system, except mine is
> less flexible. I'm going to look a little bit the code, install it and see
> if I can help you with anything.
>
> Only thing that cached my eye is that code is Copyrighted. Why not using an
> Open-source license?
>
> Thanks for your mail, regards
> Miguel Araujo
>
> 2010/9/30 mhall119 
>
>
>
> > I've recently open-sourced some code that I developed for my work
> > projects that may do at least part of what you need:
> >http://bitbucket.org/mhall119/django-extauth/wiki/Home
>
> > The basic idea is that you define a "role" that is a relationship
> > between a user and an instance of a given Model.  With your example,
> > you would created an "owner" role for your model, that somehow links
> > the user instance to the model instance.  Usually you do this directly
> > via a ForeignKey in your model, but they can be as complex as you want
> > them to be.
>
> > On Sep 30, 9:50 am, Miguel Araujo  wrote:
> > >  Hi everyone,
>
> > > I have been recently thinking about an object permission system. After
> > > reviewing Florian Apolloner (apollo13) patch for ticket
> > > #11010 and
> > > reading his article at Django
> > > Advent.
> > > I though about creating an Object Permission Rule Backend. The purpose of
> > > this message is explain you my idea, so I can receive feedback from
> > Django
> > > users and developers. This way I would like to discern if it's worth
> > coding
> > > it or if it's a good approach to a reusable solution.
>
> > > I will reuse apollo's code to elaborate my idea. My Backend would look
> > > similar to:
>
> > > class ObjectPermBackend(object):
> > >     supports_object_permissions = True
> > >     supports_anonymous_user = True
>
> > >     def authenticate(self, username, password):
> > >         return None
>
> > >     def has_perm(self, user_obj, perm, obj=None):
> > >         if not user_obj.is_authenticated():
> > >             user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
>
> > >         if obj is None:
> > >             return False
>
> > >         ct = ContentType.objects.get_for_model(obj)
>
> > >         try:
> > >             perm = perm.split('.')[-1].split('_')[0]
> > >         except IndexError:
> > >             return False
>
> > > # Simplified rule system
> > >         # Of course objects should extend an interface
> > > if (perm == "ownage")
> > > return obj.is_owned_by(user_obj)
>
> > > elif (perm == "edit")
> > > return obj.can_be_edited_by(user_obj)
>
> > > # Here be Dragons
>
> > > As I love decorators, I would like to create a permission_required
> > decorator
> > > that accepted more than a parameter, so:
>
> > > @permission_required('app.code_name') would
> > > become @permission_required('app.code_name', FLAG)
>
> > > If the FLAG is set the decorator searches in the model associated to the
> > > content type of the permission, for the name of the field for the PK. For
> > > the example imagine idArticle. Now it instantiates an object of that
> > model
> > > with Model.objects.get(pk=request.idArticle). So it would be necessary to
> > > match request parameters to model fileds (This is the best idea I've come
> > up
> > > with). Once it has the right object, it passes it to the backend for
> > > permission checks.
>
> > > I know I could do a decorator like @own_article but I'm looking for a
> > more
> > > reusable solution, that I would make open source and release at Github.
>
> > > What do you think? Is it feasible and well laid out?
>
> > > Thanks, best regards
> > > Miguel Araujo
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread Miguel Araujo
Sorry, I misunderstood it. Then everything looks great

2010/9/30 mhall119 

> The license is a 3-clause BSD style license, it's compatible with
> Django's license as far as I know.
>
> On Sep 30, 1:55 pm, Miguel Araujo  wrote:
> > Hi Michael,
> >
> > I have been looking at your project, django.extauth and I have to say I
> > really like its architecture and permission handling. I have to say that
> my
> > rule system is kind of the same thing of your role system, except mine is
> > less flexible. I'm going to look a little bit the code, install it and
> see
> > if I can help you with anything.
> >
> > Only thing that cached my eye is that code is Copyrighted. Why not using
> an
> > Open-source license?
> >
> > Thanks for your mail, regards
> > Miguel Araujo
> >
> > 2010/9/30 mhall119 
> >
> >
> >
> > > I've recently open-sourced some code that I developed for my work
> > > projects that may do at least part of what you need:
> > >http://bitbucket.org/mhall119/django-extauth/wiki/Home
> >
> > > The basic idea is that you define a "role" that is a relationship
> > > between a user and an instance of a given Model.  With your example,
> > > you would created an "owner" role for your model, that somehow links
> > > the user instance to the model instance.  Usually you do this directly
> > > via a ForeignKey in your model, but they can be as complex as you want
> > > them to be.
> >
> > > On Sep 30, 9:50 am, Miguel Araujo  wrote:
> > > >  Hi everyone,
> >
> > > > I have been recently thinking about an object permission system.
> After
> > > > reviewing Florian Apolloner (apollo13) patch for ticket
> > > > #11010 and
> > > > reading his article at Django
> > > > Advent.
> > > > I though about creating an Object Permission Rule Backend. The
> purpose of
> > > > this message is explain you my idea, so I can receive feedback from
> > > Django
> > > > users and developers. This way I would like to discern if it's worth
> > > coding
> > > > it or if it's a good approach to a reusable solution.
> >
> > > > I will reuse apollo's code to elaborate my idea. My Backend would
> look
> > > > similar to:
> >
> > > > class ObjectPermBackend(object):
> > > > supports_object_permissions = True
> > > > supports_anonymous_user = True
> >
> > > > def authenticate(self, username, password):
> > > > return None
> >
> > > > def has_perm(self, user_obj, perm, obj=None):
> > > > if not user_obj.is_authenticated():
> > > > user_obj =
> User.objects.get(pk=settings.ANONYMOUS_USER_ID)
> >
> > > > if obj is None:
> > > > return False
> >
> > > > ct = ContentType.objects.get_for_model(obj)
> >
> > > > try:
> > > > perm = perm.split('.')[-1].split('_')[0]
> > > > except IndexError:
> > > > return False
> >
> > > > # Simplified rule system
> > > > # Of course objects should extend an interface
> > > > if (perm == "ownage")
> > > > return obj.is_owned_by(user_obj)
> >
> > > > elif (perm == "edit")
> > > > return obj.can_be_edited_by(user_obj)
> >
> > > > # Here be Dragons
> >
> > > > As I love decorators, I would like to create a permission_required
> > > decorator
> > > > that accepted more than a parameter, so:
> >
> > > > @permission_required('app.code_name') would
> > > > become @permission_required('app.code_name', FLAG)
> >
> > > > If the FLAG is set the decorator searches in the model associated to
> the
> > > > content type of the permission, for the name of the field for the PK.
> For
> > > > the example imagine idArticle. Now it instantiates an object of that
> > > model
> > > > with Model.objects.get(pk=request.idArticle). So it would be
> necessary to
> > > > match request parameters to model fileds (This is the best idea I've
> come
> > > up
> > > > with). Once it has the right object, it passes it to the backend for
> > > > permission checks.
> >
> > > > I know I could do a decorator like @own_article but I'm looking for a
> > > more
> > > > reusable solution, that I would make open source and release at
> Github.
> >
> > > > What do you think? Is it feasible and well laid out?
> >
> > > > Thanks, best regards
> > > > Miguel Araujo
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, 

Can you make a subclass of a model just to alter behavior?

2010-09-30 Thread orokusaki
I'm looking to do the opposite of what Django's proxy model does. I
want to subclass Model, add some extra methods to it, add behavior to
save(), set a default manager that adds some my-application-specific
methods, and then subclass that to create most of the models in my
application. Is this possible?

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread Steve Holden
On 9/30/2010 1:55 PM, Miguel Araujo wrote:
> Hi Michael,
> 
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that
> my rule system is kind of the same thing of your role system, except
> mine is less flexible. I'm going to look a little bit the code, install
> it and see if I can help you with anything.
> 
> Only thing that cached my eye is that code is Copyrighted. Why not using
> an Open-source license? 
> 
There is a copyright on Python itself.  This doesn't stop it being
distributed under an open source license.

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

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



Re: Can you make a subclass of a model just to alter behavior?

2010-09-30 Thread Gonzalo Delgado
El 30/09/10 15:57, orokusaki escribió:
> I'm looking to do the opposite of what Django's proxy model does. I
> want to subclass Model, add some extra methods to it, add behavior to
> save(), set a default manager that adds some my-application-specific
> methods, and then subclass that to create most of the models in my
> application. Is this possible?
>   

Hmm.. I can't think of any caveats off the top of my head. Did you try that?
The only thing that smells a little like trouble to me is setting a
default manager.

-- 
Gonzalo Delgado 

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



Re: Change auth User display name in admin interface

2010-09-30 Thread Daniel Roseman
On Sep 30, 6:34 pm, Nathan  wrote:
> I'm using the django User authentication.
>
> I have a model that has a ManyToManyField which allows you to select
> several users to associate with that model. In the django admin site,
> it's set to use the filter_horizontal option.
>
> When adding a new instance of the model through the admin interface,
> it shows you the username of the User. I would like it to show the
> first_name and last_name instead. I tried using a Proxy Model and
> changing the __unicode__(self) with no success, it still shows the
> username in the admin site. I also tried inheriting from the User
> class, but it did not work either and I would rather not do it that
> way.
>
> I'm a relative noob at django, so I could very easily be missing
> something simple. Any suggestions?

The proxy model didn't work because Django has no way of knowing you
want the proxy class, rather than the base User class.

There's a hook in ModelAdmin to that allows you to specify this sort
of thing - formfield_for_foreignkey. See the documentation here:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
You could almost use that example exactly, returning your proxy class
in the queryset kwarg.
--
DR.

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



Re: Can you make a subclass of a model just to alter behavior?

2010-09-30 Thread Shawn Milochik
> 
> Hmm.. I can't think of any caveats off the top of my head. Did you try that?
> The only thing that smells a little like trouble to me is setting a
> default manager.

If you create a custom manager, then add it to each model as "objects," then 
it'll be the default (and only) manager and any code that expects a manager to 
be named 'objects' will work seamlessly.

Shawn

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



Re: Need opinion for an object permission rule backend

2010-09-30 Thread Miguel Araujo
Thanks, I already got that :)

I misunderstood the license, regards
Miguel Araujo

2010/9/30 Steve Holden 

> On 9/30/2010 1:55 PM, Miguel Araujo wrote:
> > Hi Michael,
> >
> > I have been looking at your project, django.extauth and I have to say I
> > really like its architecture and permission handling. I have to say that
> > my rule system is kind of the same thing of your role system, except
> > mine is less flexible. I'm going to look a little bit the code, install
> > it and see if I can help you with anything.
> >
> > Only thing that cached my eye is that code is Copyrighted. Why not using
> > an Open-source license?
> >
> There is a copyright on Python itself.  This doesn't stop it being
> distributed under an open source license.
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9 http://djangocon.us/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Separating application media from project media

2010-09-30 Thread Carles Barrobés
If the ideal solution for you is different sites, one authentication,
I found a reference in...
http://stackoverflow.com/questions/556907/how-to-get-distinct-django-apps-on-same-subdomain-to-share-session-cookie

...pointing to a "django-cas" application that is meant for that
purpose (Single Sign-On).
http://code.google.com/p/django-cas/

You could give it a try. (Disclaimer: didn't try it myself)


On 30 Set, 10:32, Benedict Verheyen 
wrote:
> Anyway, i was able to put the templates and media in the application
> in the end but since it was so much trouble, it probably means it's not
> the way to go. If you want code on how i did it, shoot and I'll post it here.
> There are only 2 things why i want to keep this code structure:
> - the central login shared among applications
> - if feels cleaner to share code if you're working with applications instead 
> of
>    projects.
>
> If i could do the login across projects, i would go for 1 application = 1 
> project.
>

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



what describes an url?

2010-09-30 Thread SlafS
Hi there!

I have a question about the urls.
What set of attributes of RegexURLPattern makes a "primary key" of all
the url patterns among applications in a Django project? (notice the
"" signs)

what i mean is: what is the minimal set of attributes of
RegexURLPattern that is sufficient to unambiguously describe all
urlpatterns in a Django project.

what im trying to make is an app that can show MyModel object on a
PAGE of other models/apps e.g on /page/A/. and i would like to
associate those two in an unobtrusive way. so i thought i can store in
MyModel some attributes of an url object so that i can resolve '/page/
A/' get some RegexURLPattern attributes and then search for an
appropriate MyModel object.

Is this even clear :/ ?

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



Key based session expiration

2010-09-30 Thread Thomas Gautier
Hi there!

I want my registered users to authenticate again to access some parts of my 
website but without setting the whole session expiration on browser close 
(which is done by setting set_expiry(0) if I got it correctly).

Let's say that the section I want to secure again is 
http://domain.tld/users/vault/ I've set my vault view to require a 
'has_vault_access' session key and if not, user is redirected to a vault_auth 
view which asks the user for is password before granting the session key.

The problem is I'd like this key to expire on browser close but just that key 
and not the whole user session because I'd like my user to stay connected as 
they would without that vault access thing.

So my questions are :

- Am I thinking correctly with this implementation of my "vault"?
- How can I set a session key to have a different expiration method than the 
whole session it belongs to?

Thanks in advance for your help,
Thomas Gautier.

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



Re: Tabular output

2010-09-30 Thread Martin Tiršel
Yes, I know, but what I doesn't know, is how to create these cells when  
the for loop ends.





{% for image in gallery.image_set.all %}
{% if forloop.counter0|divisibleby:gallery_cols %}


{% endif %}



{% endfor %}



Martin


On Thu, 30 Sep 2010 15:29:58 +0200, aid  wrote:




On Sep 30, 2:14 pm, Martin Tiršel  wrote:
Sorry, my bad, I thought that it has to be completed, so it is ok.  
Problem would be only if I wanted to make cell borderds, around the  
empty cells  too.


For the cells you don't have an  object to insert; try inserting
' ' instead. (Minus quotes!)  This tends to solve the border
problems.

Cheers,

aid


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



Re: Can you make a subclass of a model just to alter behavior?

2010-09-30 Thread Russell Keith-Magee
On Fri, Oct 1, 2010 at 2:57 AM, orokusaki  wrote:
> I'm looking to do the opposite of what Django's proxy model does. I
> want to subclass Model, add some extra methods to it, add behavior to
> save(), set a default manager that adds some my-application-specific
> methods, and then subclass that to create most of the models in my
> application. Is this possible?

Sounds like you're asking for an abstract base class. Set
abstract=True instead of proxy=True; only the subclasses will be
instantiated as full Django models, but they will inherit all the
methods, managers and fields of their parent.

Yours,
Russ Magee %-)

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



URL's and Multi Dimensional Filtering/Searching

2010-09-30 Thread Brendon Costa
Hi all,

I have a table with a list of data that I would like present to a user
and allow them to drill down into the data, but there are multiple
dimensions they may want to drill down into and I am not sure the best
way to do this with DJango URLs.

To give a bit of an example of what I am trying to do, say I have a
table of events which stores some information over time. I have
presented what I think is a reasonable way of designing URL's for
this.

Notice that this is basically single dimensional data, where the
dimension is time over which the data is to be presented:

/events/ (Lists all events over all time)
/events/-MM-DD/ (Lists all events since date)
/events/-MM-DD/-MM-DD/ (Lists all events in time range)

Also I want to allow users to optionally specify a offset + size to
any of the above so they can manually paginate the data (This is an
XML API). I am thinking the cleanest way to do this is allow optional
GET params like:
/events/?offset=0&size=100
/events/-MM-DD/?offset=0&size=100
/events/-MM-DD/-MM-DD/?offset=0&size=100

Now the tricky part comes if i want to filter on another dimension in
the data. Lets say the event is generated from a department within a
company. So we might have something like:

class Event(models.Model):
timestamp  = models.DateTimeField()
company= models.CharField(max_length=128)
department = models.CharField(max_length=128)
event  = models.CharField(max_length=128)

Now I was thinking of doing something like:
/events/ (Lists all events over all time, for all companies and departments)
/events/-MM-DD/ (Lists all events since date, for all companies
and departments)
/events/-MM-DD/-MM-DD/ (Lists all events in time range, for
all companies and departments)

/events// (Lists all events over all time, for all
departments of the given company)
/events//-MM-DD/ (Lists all events since date, for all
departments of the given company)
/events//-MM-DD/-MM-DD/ (Lists all events in time
range, for all departments of the given company)

/events/// (Lists all events over all time, for
the specific department in a company)
/events///-MM-DD/ (Lists all events since
date, for the specific department in a company)
/events///-MM-DD/-MM-DD/ (Lists all
events in time range, for the specific department in a company)

Now because YYY-MM-DD is a valid company name, this scheme breaks.

Is there a more general or better way to do something like this?

Thanks,
Brendon.

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



Re: Full Text Search

2010-09-30 Thread Nick Arnett
On Thu, Sep 30, 2010 at 8:34 AM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

> Is there any way to make a FULL TEXT search not in BOOLEAN MODE?
> I've found only
> http://docs.djangoproject.com/en/1.1/ref/models/querysets/#search
>
> It says it uses BOOLEAN MODE as a default, but doesn't tell how to
> avoid default..
>

Um, I hate to do this, but for the moment, I'm going to tell you "yes" - but
I can't remember how right now.  Been awake for 30 hours and waiting for a
plane to take me home!  Did a demo today for a big client, involving
Django/MySQL full text and parametric search and they loved it... so it's on
my mind.  If you don't get a real answer by tomorrow afternoon, I may be
conscious again then.  You have to use one of the alternative approaches to
search, as I recall.  Brain is mush, though.

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



Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-09-30 Thread Russell Keith-Magee
On Thu, Sep 30, 2010 at 8:01 PM, Jyrki Pulliainen  wrote:
> Hi!
>
> We encountered a possible backwards incompatibility with change 12950
> [1]. This was noticed when upgrading from 1.1.1 to 1.1.2.
>
> If I understand correctly the change 12950 removes squelching of
> ImportErrors from AppCache. AppCache in turn provides reverse-
> relations for app introspection, for example in admin interface. This
> change now causes the ImportError in one otherwise fine case to
> propagate and break the application.
>
> Funnily enough, this does not break our application per se. The webapp
> still continues to work with admin interface fully responsive, doing
> all the changes wanted, tests passing etc. This only affects a smaller
> worker script that is run via upstart.
>
> This upstart script imported a single model class (let's say, model
> class A) from a single app. However, this models.py file also had
> another model (class C) and it's admin definitions (there was actually
> no change even if these were moved to separate admin.py, we have a
> custom AdminSite object). For some reason importing this single caused
> the import error to fire. And as said before this behavior doesn't
> surface for example when running ./manage.py runserver, only trying to
> start the worker script causes the ImportError.
>
> Unfortunately this software isn't open source, but I think I can
> describe the module layout a bit though:
>
> Class A -- the "troublemaker" class has a reverse relationship with
> class B from another app, ie. class B has ForeignKeyField to A.
> Neither of these classes has any admin interface and they're not
> registered to the admin site object
> Class C -- another model in the same models.py (and app) as Class A.
> This is registed to the AdminSite.
>
> Now, when the worker starts the importing of class A causes
> ImportError due to the admin site trying to import stuff in AppCache,
> even it is not needed. The models.py it is trying to import when
> crashing is the models.py containing the Class B.
>
> Hopefully this description is even a bit helpful, even though it's a
> hard to get the whole picture without the code.

Not really -- I've tried to reproduce the 2 apps and three models you
describe, but I don't see any errors on 1.1.1 or 1.1.2.

I appreciate that you can't release your actual source code, but if
you can generate a minimal test app that reproduces the problem case,
that would be very helpful.

As I said on twitter, this general class of problem is something we've
seen before; however, in all the cases we've been able to identify so
far, it's turned out to be a legitimate error that Django was
historically (and erroneously) suppressing. Yes, 1.1.2 generates more
errors, but that's because 1.1.1 masked legitimate errors, not because
1.1.2 is broken.

If you can provide a test case that demonstrates otherwise, we're
happy to investigate.

Yours,
Russ Magee %-)

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



Re: Full Text Search

2010-09-30 Thread Steve Holden
On 9/30/2010 8:26 PM, Nick Arnett wrote:
> Brain is mush, though.

Obviously, otherwise you'd have left it in the hope that someone else
would reply with an answer before you recovered consciousness. Great
heavens, this community is *so* anxious to help. Kudos for trying with a
frazzled brain!

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

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



Re: UnicodeEncodeError

2010-09-30 Thread werefr0g
 Sorry, sorry I proposed Jean to send me the actual file to check 
its encoding. I asked for his OS too in order to see what editor are 
available and how it allows to "transcode" the text.


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



QuerySet values + annotate + order_by

2010-09-30 Thread ScottF
The background here is that I am trying to modify django-voting to
sort the objects by score, but this is a general question.

The following code works minus the order_by statement on the end:

   queryset = self.filter(
object_id__in = object_ids,
content_type = ctype,
).values(
'object_id',
).annotate(
score = CoalesceSum('vote', default='0'),
num_votes = CoalesceCount('vote', default='0'),
).order_by('score')

Without the order_by statement, I get the following result:

[{'score': 1, 'object_id': 2, 'num_votes': 1}, {'score': -1,
'object_id': 3, 'num_votes': 1}, {'score': 1, 'object_id': 4,
'num_votes': 1}]

but when adding order_by, I get the following error:

FieldError: Cannot resolve keyword 'score' into field. Choices are:
content_type
, id, object_id, user, vote

The choices listed belong to the "Vote" model.  But why aren't the
available choices 'object_id' (from the values statement) and 'score'
and 'num_votes' (from the annotate statement)?  I thought you could do
an order by anything in an annotate statement.

Thanks,
Scott



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



Re: template syntax errors in production admin site (version problem?)

2010-09-30 Thread Karen Tracey
On Thu, Sep 30, 2010 at 12:39 PM, bobbymanuel wrote:

> PROBLEM SOLVED:  upgrade to Python 2.7 on server resolved issue.
> Apparrently Django 1.2.3 is not fully compatible with Python 2.5
>

I suspect it is your application code, not Django 1.2.3, that is not
compatible with Python 2.5. The error you mentioned above was:

TemplateSyntaxError at /admin/
In template
/usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/base.html,
error at line 31
Caught SyntaxError while rendering: invalid syntax (views.py, line 52)

This is saying that line 52 of a views.py file is where the Python syntax
error was encountered.My guess is you have some code on line 52 in some
views.py file in your project that uses Python syntax that was not allowed
in Python 2.5.

Why was that line even getting referenced from an attempt to load /admin/?
Line 31 of the admin/base.html template is:

31  {% url django-admindocs-docroot as docsroot %}

This {% url %} tag (any {% url %} tag) will cause all of your project's url
patterns to get loaded, which will often lead to importing your project's
view code.

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

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



Re: UnicodeEncodeError

2010-09-30 Thread Karen Tracey
On Wed, Sep 29, 2010 at 5:32 PM, werefr0g  wrote:

>  Sorry, sorry I proposed Jean to send me the actual file to check its
> encoding. I asked for his OS too in order to see what editor are available
> and how it allows to "transcode" the text.
>

Not the contents of the file is irrelevant to this problem: it is the file's
name that is causing the problem. The last bit of the traceback is:

 File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line 18, in
exists
   st = os.stat(path)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position
53: ordinal not in range(128)

"path" here includes the file name, no file data is involved. Django is
passing a unicode string "path" to the os.stat() function. On many operating
systems, Python must actually pass a bytestring, not unicode, to the
underlying OS routine that implements "stat".  Therefore Python must convert
the unicode string to a bytestring using some encoding. The encoding it uses
is whatever is returned by os.getfilesystemencoding:
http://docs.python.org/library/sys.html#sys.getfilesystemencoding. As noted
in that documentation, on Unix the encoding will be:

... the user’s preference according to the result of nl_langinfo(CODESET),
or None if the nl_langinfo(CODESET) failed.

That's a pretty obscure description but it boils down to the encoding
associated with the currently set locale. (And on some systems successfully
setting a locale with an encoding like utf-8 requires installing some
"extra" language packs.) So the key to fixing this problem is to ensure the
locale of the running server is successfully set to one with an encoding
such as utf-8, which supports (can encode) the full range of unicode values.
Unfortunately details on setting locales differs from machine to machine so
it is hard to give specific instructions here.

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

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



Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

2010-09-30 Thread Jyrki Pulliainen
On Oct 1, 3:30 am, Russell Keith-Magee 
wrote:
> Not really -- I've tried to reproduce the 2 apps and three models you
> describe, but I don't see any errors on 1.1.1 or 1.1.2.
>
> I appreciate that you can't release your actual source code, but if
> you can generate a minimal test app that reproduces the problem case,
> that would be very helpful.
>
> As I said on twitter, this general class of problem is something we've
> seen before; however, in all the cases we've been able to identify so
> far, it's turned out to be a legitimate error that Django was
> historically (and erroneously) suppressing. Yes, 1.1.2 generates more
> errors, but that's because 1.1.1 masked legitimate errors, not because
> 1.1.2 is broken.
>
> If you can provide a test case that demonstrates otherwise, we're
> happy to investigate.

I managed to create a simulation of the situation (I suggest hitting
the download button or using git, it seems to give the correct
directory structure, the gist is a bit fubar as it doesn't appreciate
directories):

http://gist.github.com/605838

Seems to work exactly like our system does: If the app is started
via ./manage.py runserver it starts up fine and displays the 404. The
admin works fine and I can edit the model C just fine there. However,
if I try to run the runner.py provided in the root directory the
'foobar' newer gets printed and instead the app crashes to an import
error. This is why I'm suspecting there's some difference with the
order of importing stuff and manage.py seems to get the order right.

If I checkout Django version pre-12950 both the admin and runner.py
work just fine (as the ImportError gets swallowed).

- Jyrki

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