Re: Current Django 1.3 Alpha 2 Documentation as PDF

2010-11-25 Thread derek
Please post a link to the PDF when the final release is available.

On Nov 21, 7:38 pm, "ckar...@googlemail.com" 
wrote:
> Sry for dublepost.
>
> For those who don't want to install all the *tex* libraries. Here is
> the link:http://ubuntuone.com/p/QFl/
>
> Have fun with printing and reading ;-)
>
> On 21 Nov., 18:00, "ckar...@googlemail.com" 
> wrote:
>
> > Are you interested in the current Django 1.3 Alpha 2 documentation as
> > PDF?

-- 
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: tutorial part 4: ImportError

2010-11-25 Thread steph
>>> import django.views.generic
>>> dir (django.views.generic)
['GenericViewError', '__builtins__', '__doc__', '__file__',
'__name__', '__package__', '__path__', 'list_detail']

ok, I can see list_detail now :-) ... but the other?

maybe a problem with my installation ...

On 23 Nov., 17:37, Michael Sprayberry 
wrote:
> Steph,
>  
> those instructions are incorrect try
> from djanog.views.generic import list_view, list_detail
>  
> Michael
>
> --- On Tue, 11/23/10, steph  wrote:
>
> From: steph 
> Subject: tutorial part 4: ImportError
> To: "Django users" 
> Date: Tuesday, November 23, 2010, 11:06 AM
>
> Hi group,
>
> I'm new - just worked thgough the tutorial. In part 4 about the use of
> generic views I've got a problem - I can't import ListView and
> DetailView:
>
> >>> from django.views.generic import DetailView
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: cannot import name DetailView>>> from django.views.generic 
> import ListView
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: cannot import name ListView
>
> I'm on the newest version of django: first tried with version 1.2.3,
> then I upgraded to 1.3 alpha - same problem.
>
> Any clues?
>
> thanks,
> stephan
>
> ps: other than that it's a great tutorial!
>
> --
> 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: tutorial part 4: ImportError

2010-11-25 Thread steph


On 23 Nov., 17:44, Daniel Roseman  wrote:
> On Nov 23, 4:06 pm, steph  wrote:
>
>
>
> > Hi group,
>
> > I'm new - just worked thgough the tutorial. In part 4 about the use of
> > generic views I've got a problem - I can't import ListView and
> > DetailView:
>
> > >>> from django.views.generic import DetailView
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ImportError: cannot import name DetailView>>> from django.views.generic 
> > import ListView
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ImportError: cannot import name ListView
>
> > I'm on the newest version of django: first tried with version 1.2.3,
> > then I upgraded to 1.3 alpha - same problem.
>
> > Any clues?
>
> > thanks,
> > stephan
>
> > ps: other than that it's a great tutorial!
>
> Are you sure you've upgraded correctly? It won't work at all if you
> have anything less than 1.3 alpha - the tutorial you're using is for
> the development version only (there's a big link at the top of the
> page for the one that works in previous versions), and generic views
> are one big element that has changed since 1.2. How did you install
> 1.3?
> --
> DR.

Ok, sorry - didn't get it about the tutorial versions ... it didn't
appear to me that 1.2 tutorial was about version 1.2.3. - silly me ;-)

How I did install 1.3: download ... setup.py. Just as in INSALL-file.

-- 
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: tutorial part 4: ImportError

2010-11-25 Thread Robbington
As mentioned before,

If you are using Django 1.2 you dont need to import list_view or
detail_view just 'from django.conf.urls.defaults import *'

As the tutorial documentation for 1.2 
http://docs.djangoproject.com/en/1.2/intro/tutorial04/
instructs:

from django.conf.urls.defaults import *
from polls.models import Poll

info_dict = {
'queryset': Poll.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list',
info_dict),
(r'^(?P\d+)/$',
'django.views.generic.list_detail.object_detail', info_dict),
url(r'^(?P\d+)/results/$',
'django.views.generic.list_detail.object_detail', dict(info_dict,
template_name='polls/results.html'), 'poll_results'),
(r'^(?P\d+)/vote/$', 'polls.views.vote'),
)

Rob

-- 
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 bug with __iexact

2010-11-25 Thread bruno desthuilliers
On 24 nov, 16:13, felix  wrote:
> from django.contrib.auth.models import *
>  User.objects.filter(username__iexact="/turtle")
>
> *** ValueError: list.index(x): x not in list
>
> URL:http://code.djangoproject.com/svn/django/trunk
> Repository Root:http://code.djangoproject.com/svn
> Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
> Revision: 13265

Felix:

1/ Please consider posting a full traceback - tracebacks are here to
help understanding what went wrong  - and possibly where.
2/ It's the user discussion group here, not the bug tracking system
3/ If you're working on the trunk, before you fill a bug report,
update to the lattest revision.

FWIW, your above code works just fine here using r13696 which is
already quite a few weeks old.

-- 
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.



tree data structure

2010-11-25 Thread pa_ree
i want to create a tree data structure for an organizational project
for eg at the root level i want the project leader, under him would
work the project manger, under him the project members and so on
plz help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: tree data structure

2010-11-25 Thread Daniel Roseman
On Nov 25, 10:47 am, pa_ree  wrote:
> i want to create a tree data structure for an organizational project
> for eg at the root level i want the project leader, under him would
> work the project manger, under him the project members and so on
> plz help

http://github.com/django-mptt/django-mptt

-- 
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: 'is None' in {% if %}

2010-11-25 Thread Łukasz Rekucki
On 25 November 2010 03:48, Christophe Pettus  wrote:
> I have a Decimal field that's blank=True, null=True, and NULL and 0.0 are 
> distinct values.  I'd like to do something different in a template depending 
> on whether or not the value is None or not, but a standard {% if field %} 
> treats 0.0 and None the same.  Right now, I'm checking is None in the 
> application and setting a separate value in the context, but is there a way 
> of doing this directly on the field itself?

In Django 1.2, {% if value == None %} seems to work fine.

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



confirm user by ref_has and email

2010-11-25 Thread robos85
I'm wondering how to confirm user by ref_hash and email. I know how to
check by ref_hash in my UserProfile model but have no idea how to
connect users model with my UserProfile model.
It's required because I'm checking email (Users) and reg_hash
(UserProfile).

How to resolve it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: confirm user by ref_has and email

2010-11-25 Thread robos85
EDIT - title should be: "confirm user by reg_hash and email"

On 25 Lis, 12:55, robos85  wrote:
> I'm wondering how to confirm user by ref_hash and email. I know how to
> check by ref_hash in my UserProfile model but have no idea how to
> connect users model with my UserProfile model.
> It's required because I'm checking email (Users) and reg_hash
> (UserProfile).
>
> How to resolve it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



Image upload in Django

2010-11-25 Thread Sithembewena Lloyd Dube
Hi folks,

I have a Member model representing a site user. I wish to add functionality
to allow users to upload images to their profiles, and I need a pointer to a
*simple* file upload solution for Django.

Any ideas?

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

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



Re: Image upload in Django

2010-11-25 Thread Venkatraman S
On Thu, Nov 25, 2010 at 6:10 PM, Sithembewena Lloyd Dube
wrote:

>
> I have a Member model representing a site user. I wish to add functionality
> to allow users to upload images to their profiles, and I need a pointer to a
> *simple* file upload solution for Django.
>

I am not sure what is the actual problem. Just have an imagefield in the
model ?

-V-
http://twitter.com/venkasub

-- 
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: Image upload in Django

2010-11-25 Thread Sithembewena Lloyd Dube
:) Thanks Venkatraman, I noted with embarrassment that it's painless via the
model, somewhere in the docs.

Thanks.

On Thu, Nov 25, 2010 at 3:02 PM, Venkatraman S  wrote:

>
> On Thu, Nov 25, 2010 at 6:10 PM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>>
>> I have a Member model representing a site user. I wish to add
>> functionality to allow users to upload images to their profiles, and I need
>> a pointer to a *simple* file upload solution for Django.
>>
>
> I am not sure what is the actual problem. Just have an imagefield in the
> model ?
>
> -V-
> http://twitter.com/venkasub
>
>  --
> 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.
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

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



Re: confirm user by ref_has and email

2010-11-25 Thread bruno desthuilliers
On 25 nov, 12:55, robos85  wrote:
> I'm wondering how to confirm user by ref_hash and email. I know how to
> check by ref_hash in my UserProfile model but have no idea how to
> connect users model with my UserProfile model.
> It's required because I'm checking email (Users) and reg_hash
> (UserProfile).
>
> How to resolve it?

Your UserProfile has a key to User, does it ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: tree data structure

2010-11-25 Thread bruno desthuilliers
On 25 nov, 11:58, Daniel Roseman  wrote:
> On Nov 25, 10:47 am, pa_ree  wrote:
>
> > i want to create a tree data structure for an organizational project
> > for eg at the root level i want the project leader, under him would
> > work the project manger, under him the project members and so on
> > plz help
>
> http://github.com/django-mptt/django-mptt

mptt is not the only way to model trees in a RDBMS, and it's not
necessarily the most efficient, depending on the tree characteristics
and typical usage.

-- 
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.



mysql default connection timeout

2010-11-25 Thread Henrik Genssen
Hi,

can someone tell me, what the default connection timeout is for mysql using 
django? 
The docs only tell, how to overwrite the defaults...

regards

Henrik

-- 
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: tree data structure

2010-11-25 Thread bruno desthuilliers
On 25 nov, 11:47, pa_ree  wrote:
> i want to create a tree data structure for an organizational project
> for eg at the root level i want the project leader, under him would
> work the project manger, under him the project members and so on


Do you really need a tree to represent this ? What's your use case ?
(I mean: what are you going to do with these data ? Are these
"persons" (=>"Project leader" "Project manager", "members" etc) users
of the system or just entities ? What are the relationships between a
"person" and a "project" ? Do you only have one and only project or
many ? Can a "person" be related to different projects ? With
different "roles" ? etc, etc, etc...

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



Re: newbie admin question

2010-11-25 Thread Jason Mayfield
In this particular example, you have Character model being an inline of itself.

On Nov 24, 2010, at 8:07 PM, eric wrote:

> Well, there are a number of models, so I'll just give an example of
> the one that is misbehaving:
> 
> 
> from pages.models import Chapter
> from django.contrib import admin
> 
> class CharacterInline(admin.StackedInline):
>model = Character
> 
> class CharacterAdmin(admin.ModelAdmin):
>inlines = [CharacterInline]
>list_display = ('name','role')
>fieldsets = [
> (None, {'fields':['name', 'role',
> 'stories', 'rank']}),
> ('content',  {'fields':['content']})]
> admin.site.register(Character, CharacterAdmin)
> 
> Repeat that for all the other 8 or 9 models, with appropriate fields.
> 
> Since I'm still working through the tutorial, I created the Inline/
> Admin classes after my first attempt at registering the class-so, it
> used to simply be:
> 
> from pages.models import Character,Other,Classes
> from django.contrib import admin
> 
> admin.site.register([Character,bunch, of, other,classes])
> 
> 
> On 11/24/10 2:04 PM, Jason Mayfield wrote:
>> Can you provide your admin.py file?
>> 
>> - Jason
>> 
> 
> -- 
> 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.
> 

- Jason

-- 
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: confirm user by ref_has and email

2010-11-25 Thread robos85
Yes it looks that:
from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
register_hash = models.CharField(max_length=32)

And now I want to do something like this:
check = User.objects.all()

for x in check:
print x.userprofile.register_hash

And I get :
'User' object has no attribute 'userprofile'

On 25 Lis, 14:43, bruno desthuilliers 
wrote:
> On 25 nov, 12:55, robos85  wrote:
>
> > I'm wondering how to confirm user by ref_hash and email. I know how to
> > check by ref_hash in my UserProfile model but have no idea how to
> > connect users model with my UserProfile model.
> > It's required because I'm checking email (Users) and reg_hash
> > (UserProfile).
>
> > How to resolve it?
>
> Your UserProfile has a key to User, does it ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Current Django 1.3 Alpha 2 Documentation as PDF

2010-11-25 Thread ckar...@googlemail.com
Okay, please remind me ;-)

On 25 Nov., 09:38, derek  wrote:
> Please post a link to the PDF when the final release is available.
>
> On Nov 21, 7:38 pm, "ckar...@googlemail.com" 
> wrote:
>
>
>
>
>
>
>
> > Sry for dublepost.
>
> > For those who don't want to install all the *tex* libraries. Here is
> > the link:http://ubuntuone.com/p/QFl/
>
> > Have fun with printing and reading ;-)
>
> > On 21 Nov., 18:00, "ckar...@googlemail.com" 
> > wrote:
>
> > > Are you interested in the current Django 1.3 Alpha 2 documentation as
> > > PDF?

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



Re: newbie admin question

2010-11-25 Thread Eric Torstenson
Ah, and the name is so clear-but I misinterpreted it thinking it was
strictly layout.

On Thu, Nov 25, 2010 at 7:58 AM, Jason Mayfield wrote:

> In this particular example, you have Character model being an inline of
> itself.
>
> On Nov 24, 2010, at 8:07 PM, eric wrote:
>
> > Well, there are a number of models, so I'll just give an example of
> > the one that is misbehaving:
> >
> >
> > from pages.models import Chapter
> > from django.contrib import admin
> >
> > class CharacterInline(admin.StackedInline):
> >model = Character
> >
> > class CharacterAdmin(admin.ModelAdmin):
> >inlines = [CharacterInline]
> >list_display = ('name','role')
> >fieldsets = [
> > (None, {'fields':['name', 'role',
> > 'stories', 'rank']}),
> > ('content',  {'fields':['content']})]
> > admin.site.register(Character, CharacterAdmin)
> >
> > Repeat that for all the other 8 or 9 models, with appropriate fields.
> >
> > Since I'm still working through the tutorial, I created the Inline/
> > Admin classes after my first attempt at registering the class-so, it
> > used to simply be:
> >
> > from pages.models import Character,Other,Classes
> > from django.contrib import admin
> >
> > admin.site.register([Character,bunch, of, other,classes])
> >
> >
> > On 11/24/10 2:04 PM, Jason Mayfield wrote:
> >> Can you provide your admin.py file?
> >>
> >> - Jason
> >>
> >
> > --
> > 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.
> >
>
> - Jason
>
> --
> 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.



Key 'buscar' not found in "

2010-11-25 Thread bvcelari
Hy,
I'm trying to deploy my first django app, and I'm trying to use
pagination , I 'm using Django 1.2
I'm using a simple view with form, and with the request show the
results paginated. when I try to go to next page
the message appears:
"Key 'buscar' not found in "
buscar is a hidden value used for check if the request comes from the
search form.
I think this message comes from the "request" URL is not properly
generated in fact my link targets to
"http://localhost:8000/search/?page=2";
instead of something like this:
"http://localhost:8000/search/?option_value1=7&option_value2=3&page=2";
There is any way to maintain the searchred url and indicate wich is
the next page?
Down is my code like
(apologise my worst english)





#views.py
def search(request):

errors = []
mi_form = BuscaForm(request.GET)
  if request.GET and request.GET['buscar']=='1'
###here is my search filters

encontrados = My_first_model.objects.filter(q)
mi_paginator = Paginator(encontrados, 2)

try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1

try:
pg_encontrados = mi_paginator.page(page)
except (EmptyPage, InvalidPage):
pg_encontrados =
mi_paginator.page(mi_paginator.num_pages)

 return render_to_response('search_results.html',
{'encontrados': encontrados,
 'pg_encontrados': pg_encontrados,}


#search_results.html

{% if pg_encontrados.object_list %}
{% for nodo in encontrados %}
   {{ nodo.id }}
{% endfor %}
{% endif %}

{% if pg_encontrados.has_previous %}
anterior
{% endif %}

Pg {{ pg_encontrados.number }} de
{{ pg_encontrados.paginator.num_pages }}.

{% if pg_encontrados.has_next %}
siguiente
{% endif %}


Thanks
Bvcelari

-- 
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 feeds sometimes generate AttributeError: 'LatestStripsByStripConfig' object has no attribute '__name __'

2010-11-25 Thread marty3d
Hi!

My site have started to behave a little weird.

Lately, I get two or three errors per day, saying:
Traceback (most recent call last):

 File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
packages/django/core/handlers/base.py", line 95, in get_response
   response = middleware_method(request, callback, callback_args,
callback_kwargs)

 File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
packages/django/middleware/doc.py", line 18, in process_view
   response['X-View'] = "%s.%s" % (view_func.__module__,
view_func.__name__)

AttributeError: 'LatestStripsByStripConfig' object has no attribute
'__name__'

I don't know why this is appearing all of a sudden, I haven't changed
the code, but I don't know where to start debugging this.

Here is my feeds.py, rather straightforward:
from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404

from strip.models import StripConfig, Strip

class LatestStripsByStripConfig(Feed):
#__name__ = 'LatestStripsByStripConfig'
description_template = 'feeds/latest_description.html'

def get_object(self, request, stripconfig):
return get_object_or_404(StripConfig, slug=stripconfig)

def title(self, obj):
return "Scandinavian Comics RSS feed for %s" % obj.strip_name

def link(self, obj):
return "%s?utm_source=feed&utm_medium=%s" %
(obj.get_absolute_url(), obj.strip_name)

def description(self, obj):
return "The latest %s comic strips. See more at
http://www.scandinavian-comics.com/strips/"; % obj.strip_name

def items(self, obj):
return
Strip.objects.filter(strip_config__slug=obj.slug).order_by('-date')[:
10]

def item_link(self, item):
return "%s?utm_source=feed&utm_medium=%s&utm_campaign=%s" %
(item.get_absolute_url(), item.strip_config, item)


Does anyone have some wise suggestions? I would really appreciate it!
Thank you!

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



Re: Django feeds sometimes generate AttributeError: 'LatestStripsByStripConfig' object has no attribute '__name __'

2010-11-25 Thread Łukasz Rekucki
Well, something must have changed if you didn't had the problem
before. What version of Django are you running ?

On 25 November 2010 15:38, marty3d  wrote:
> Hi!
>
> My site have started to behave a little weird.
>
> Lately, I get two or three errors per day, saying:
> Traceback (most recent call last):
>
>  File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
> packages/django/core/handlers/base.py", line 95, in get_response
>   response = middleware_method(request, callback, callback_args,
> callback_kwargs)
>
>  File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
> packages/django/middleware/doc.py", line 18, in process_view
>   response['X-View'] = "%s.%s" % (view_func.__module__,
> view_func.__name__)
>
> AttributeError: 'LatestStripsByStripConfig' object has no attribute
> '__name__'
>
> I don't know why this is appearing all of a sudden, I haven't changed
> the code, but I don't know where to start debugging this.
>
> Here is my feeds.py, rather straightforward:
> from django.contrib.syndication.views import Feed
> from django.shortcuts import get_object_or_404
>
> from strip.models import StripConfig, Strip
>
> class LatestStripsByStripConfig(Feed):
>    #__name__ = 'LatestStripsByStripConfig'
>    description_template = 'feeds/latest_description.html'
>
>    def get_object(self, request, stripconfig):
>        return get_object_or_404(StripConfig, slug=stripconfig)
>
>    def title(self, obj):
>        return "Scandinavian Comics RSS feed for %s" % obj.strip_name
>
>    def link(self, obj):
>        return "%s?utm_source=feed&utm_medium=%s" %
> (obj.get_absolute_url(), obj.strip_name)
>
>    def description(self, obj):
>        return "The latest %s comic strips. See more at
> http://www.scandinavian-comics.com/strips/"; % obj.strip_name
>
>    def items(self, obj):
>        return
> Strip.objects.filter(strip_config__slug=obj.slug).order_by('-date')[:
> 10]
>
>    def item_link(self, item):
>        return "%s?utm_source=feed&utm_medium=%s&utm_campaign=%s" %
> (item.get_absolute_url(), item.strip_config, item)
>
>
> Does anyone have some wise suggestions? I would really appreciate it!
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Key 'buscar' not found in "

2010-11-25 Thread Nick Arnett
On Thu, Nov 25, 2010 at 6:35 AM, bvcelari  wrote:

> Hy,
> I'm trying to deploy my first django app, and I'm trying to use
> pagination , I 'm using Django 1.2
> I'm using a simple view with form, and with the request show the
> results paginated. when I try to go to next page
> the message appears:
> "Key 'buscar' not found in "
> buscar is a hidden value used for check if the request comes from the
> search form.
> I think this message comes from the "request" URL is not properly
> generated in fact my link targets to
> "http://localhost:8000/search/?page=2";
> instead of something like this:
> "http://localhost:8000/search/?option_value1=7&option_value2=3&page=2";
> There is any way to maintain the searchred url and indicate wich is
> the next page?


You need to pass that variable to the template, then add it to the page it
as a hidden input.

For example:



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: tree data structure

2010-11-25 Thread pa_ree
the idea is basically that there are people in an organization who are
working in various projects under different roles.
so i want to represent the project hierarchy in the form of an
inverted tree structure. i also want it to be dynamic that is when a
new project is assigned to a person say who is wrking at the
managerial level to be upgraded to the next higher level.
one person can work in various projects with different roles and one
project has various persons involved.

i wud be realy grateful if u cud come out wid the solution as to how
do i implememnt this.

-- 
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.



Building Privacy Options Like Facebook with Django

2010-11-25 Thread Corey
I was trying to build a website that would be a good idea to have
privacy options to hide certain data such as Facebook does with
personal info. I am a somewhat newbie to Django and website building
in general. So Im trying to wrap my head around how to work on this. I
have indeed tried to look on Google to find something regarding this
but have had no luck. Any pointers or tutorial links regarding this
would be greatly appreciated. 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.



Central Login with Redirecting users based on Groups

2010-11-25 Thread stefanvonfintel
Hi all.

I am new to Django and have just recently started using it for a new
project at our company.
I have a bit of problem at the moment. What I would ideally like is to
have one central login for users and then redirect them based on the
groups that
they belong to once they have been authenticated successfully ie. for
managers they get redirected to www.example.com/manager/ and for
normal
users they get redirected to www.example.com/users/.

I have searched google and the forums for a while and can not get an
answer to this question.
So I have given up on that idea that's why at the moment I have got
two different login forms one on /users/ and one on /managers/. But
they are both using the login() and authenticate() functions that are
built in to django. This is a problem since if you login to /users/
then you have access to /managers/ without logging in there. Or is the
some other way that I am completely missing?

-- 
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.



One-to-One relation with abstract classes

2010-11-25 Thread Clemens Wältken

Hey everyone!
Iam new to this mailinglist and django + python in general.
Yesterday I came up with a pretty complex question concerning abstract 
classes and relations.

I have modeled the following classes:

Question
/Answer
/YesNoAnswer
FreeAnswer

Answer should be abstract (note the italic text;) and has a one-to-one 
relation to question.
In django both directions of this relation are navigable (by default) 
and this is intended, BUT by adding more concrete classes of Answer i 
automaticly create new fields in Question, like yesnoanswer and 
freeanswer and maybe many more. This kindof breaks the one-to-one 
relationship. In an ideal world id like to access the concrete Answer by 
calling Question.answer, i therefore wrote the kinda handy method 
getAnswer() to emulate this behavior. Is there a more elegant way to do 
this? Did i miss something in the django documentation? (Note that 
setting the related_name wont do the trick)
Another thing is that the getAnswer method somehow breaks autocompletion 
in my iPython shell, but that's just a minor issue.


---

class Question(models.Model):
text = models.CharField(max_length=500)
def __unicode__(self):
return self.text

def getAnswer(self):
for c in Antwort.__class__.__subclasses__(Answer):
try:
return self.__getattribute__(c.__name__.lower())
except:
continue
return None

class Answer(models.Model):
Question = models.OneToOneField(Question)
class Meta:
abstract = True

class YesNoAnswer(Answer):
value = models.BooleanField(default = True)

class FreeAnswer(Answer):
value = models.CharField(max_length = 150)

---

--
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.



Custom Login using model form

2010-11-25 Thread PRANAV HEGDE
Hi guys,

I'm trying to create a login form using a model form,

user model:
class users(models.Model):
username = models.CharField(max_length=20, primary_key=True)
password = models.CharField(max_length=50)
usertype = models.CharField(max_length=20)
class Meta:
db_table = u'users'

login form:
class loginlorm(forms.ModelForm):
class Meta:
model = users
fields = ('username','password','usertype')
widgets = {
'username':TextInput(),
'password':PasswordInput(),
'usertype':Select(choices=(("t1","type1"),
("t2","type2"))),
   }

The form comes up as i wanted it to, but when i login it gives a
validation error saying "user with this name already exists".
I think its "form.is_valid()" checking "primary key" constraint,
thinking i'm trying to write into the table. :(
I cant remove the "primary key" constraint on "username" is there a
way around this problem..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: percentage of models given field value?

2010-11-25 Thread Eric Torstenson

Why not make a function in the model return those results?
On 11/24/10 10:13 PM, Lachlan Musicman wrote:

On Thu, Nov 25, 2010 at 13:44, Christophe Pettus  wrote:

On Nov 24, 2010, at 4:37 PM, Lachlan Musicman wrote:

Using django 1.2 I wanted to present some statistics on the data that
we have been collecting in our db.

We have source texts with authors, and target texts with their translators.

The target text model has a value "Language".

I get the count of the target texts: all, and then filtered by
language. How would I present each language as a percentage of the
total target text count?

This is a great query to write as SQL, rather than using the ORM (I love the 
Django ORM, but the right tools for the right job).

Assuming more or less standard Django names, you could return a list of the 
languages, the total number of texts for each language, and the percentage of 
the total with something along the lines of:

SELECT language, COUNT(*), (COUNT(*)/(SELECT COUNT(*) FROM 
app_targettexts))
FROM app_targettexts
GROUP BY language

This has the advantage that it only hits the database once.  If you need the 
grand total, you can either calculate it in the application, or thorw on:

UNION
SELECT 'total', COUNT(*), 1.0 FROM app_targettexts

Thanks Christopher. I've never done raw SQL in Django before. This may
seem like a silly follow up question, but is it standard practice to
put the relevant code, as described by the documentation
(http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
) into views.py?

cheers
L.



--
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.



settings.DEBUG=False in django 1.2.1 and no mail connection

2010-11-25 Thread Sells, Fred
I'm trying to get django to email exceptions to me, now that my app is
in production.  I'm testing under Windows7 but will deploy under Linux
CENTOS

The following code works as a test (server names changed to protect the
innocent:
from django.core.mail import EmailMessage
import os
def run():
filenames = os.listdir('.')
filenames = [x for x in filenames if x.endswith('.py')]

subject = "django email test"
message = "this is a test"
email = EmailMessage(subject, message, 'mds30 server',
[...@mydomain.org'], )
for filename in filenames:
email.attach_file(filename)
email.send()

===
However I cannot get django to email exceptions to me. But it is
detecting them.  Code snippets follow

---settings.py
DEBUG = False
TEMPLATE_DEBUG = True  #also tried False

ADMINS = (
 ('Fred Sells', m...@mydomain.org'),
)
EMAIL_HOST = "mail.mydomain.org"
EMAIL_HOST_USER = ''  #also tried with my username and password
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = 'frse...@mydomain.org'
SERVER_EMAIL = 'frse...@mydomain.org'
MANAGERS = ADMINS

--I've put some print statements in core/handlers.base.py
and it seems ok
print 'a', subject 
try:
request_repr = repr(request)
except:
request_repr = "Request repr() unavailable"
message = "%s\n\n%s" % (self._get_traceback(exc_info),
request_repr)
print 'bb', message
print 'ccc', resolver.urlconf_module
mail_admins(subject, message, fail_silently=False)
# If Http500 handler is not installed, re-raise last exception
if resolver.urlconf_module is None:
raise exc_info[1], None, exc_info[2]
# Return an HttpResponse that displays a friendly error message.
callback, param_dict = resolver.resolve500()
print 'dd',  callback, param_dict

which shows...

what you would expect, ending with
ccc 
core.mail None
dd  {}

but when I look at core/mail/__init__.py I see
this
def mail_admins(subject, message, fail_silently=False, connection=None):
"""Sends a message to the admins, as defined by the ADMINS
setting."""
if not settings.ADMINS: 
return
print 'core.mail', connection
EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
 settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
 
connection=connection).send(fail_silently=fail_silently)

--which prints
core.mail None

looking at the code, I see that base does not pass a connection, but
mail expects one and defaults to None.  Obviously others are using this
ok, so I must be missing something.  Can someone explain what I'm
missing.



-- 
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: Central Login with Redirecting users based on Groups

2010-11-25 Thread Knut Ivar Nesheim
Hi Stefan,

If you roll your own login view, this can be done by simply
redirecting to the correct url after authentication. You would have to
come up with the correct url by looking at the groups. Consider
something like this:

def login_view(request):
# login and authenticate..
user = User object

url = get_redirect_url(user)
return HttpResponseRedirect(url)

def get_redirect_url(user):
if user.groups.filter(name = 'Manager'):
return '/managers'/
   elif user.groups.filter(name = 'Users'):
return '/users/'

   return '/'

This could be further improved by using some Django helpers, like
'redirect' and 'reverse'.

If you have many groups, you could improve this by having a dict
mapping group name to url. Consider something like this in your
settings

LOGIN_URL_MAP = {
'Managers': '/managers'/,
'Users': '/users':
}

Then 'get_redirect_url' could look something like this:

def get_redirect_url(user):
url = '/'
for group in user.groups.all():
url = settings.LOGIN_URL_MAP[group.name]

return url

Regards
Knut

On Thu, Nov 25, 2010 at 10:24 AM, stefanvonfintel
 wrote:
> Hi all.
>
> I am new to Django and have just recently started using it for a new
> project at our company.
> I have a bit of problem at the moment. What I would ideally like is to
> have one central login for users and then redirect them based on the
> groups that
> they belong to once they have been authenticated successfully ie. for
> managers they get redirected to www.example.com/manager/ and for
> normal
> users they get redirected to www.example.com/users/.
>
> I have searched google and the forums for a while and can not get an
> answer to this question.
> So I have given up on that idea that's why at the moment I have got
> two different login forms one on /users/ and one on /managers/. But
> they are both using the login() and authenticate() functions that are
> built in to django. This is a problem since if you login to /users/
> then you have access to /managers/ without logging in there. Or is the
> some other way that I am completely missing?
>
> --
> 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: django ticket tracking

2010-11-25 Thread Karen Tracey
On Wed, Nov 24, 2010 at 10:12 AM, felix  wrote:

> The django ticket system regards everything as spam.
>
> There doesn't seem to be a way to get a password reset.
>
> I created a new account, verified it, but the username/password or the
> email/password still do not work to login.
>
> anybody have any advice as to what to do now ?
>
>
Should be username/password, not email/password that works. There is a
password reset page here:
http://www.djangoproject.com/accounts/password/reset/

An alternative way to get around the spam filter is to set some session
settings here: http://code.djangoproject.com/settings

(I used those session setting for a long time before I ever created a login,
but that was years ago now. I assume it still works to avoid the spam
filter.)

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: Reloading a single model object from .py file... keeps getting cached results?

2010-11-25 Thread Karen Tracey
On Wed, Nov 24, 2010 at 3:34 PM, Jumpfroggy  wrote:

> I want to run a script outside of the django server for maintenance
> purposes, but it still accesses some of the models.  The problem is
> that I can't seem to get the model object to reload it's data from the
> DB - it always seems cached.
> [code snipped]


What database? If MySQL/InnoDB I think you are seeing the result of its
default "repeatable read" transaction isolation level. More details in this
thread:

http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d/

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: auth_user first_name and last_name editing

2010-11-25 Thread BozoJoe
So no builtin views and urls in any modules?

-- 
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: Custom Login using model form

2010-11-25 Thread Daniel Roseman
On Nov 25, 7:53 am, PRANAV HEGDE  wrote:
> Hi guys,
>
> I'm trying to create a login form using a model form,
>
> user model:
> class users(models.Model):
>     username = models.CharField(max_length=20, primary_key=True)
>     password = models.CharField(max_length=50)
>     usertype = models.CharField(max_length=20)
>     class Meta:
>         db_table = u'users'
>
> login form:
> class loginlorm(forms.ModelForm):
>     class Meta:
>         model = users
>         fields = ('username','password','usertype')
>         widgets = {
>                     'username':TextInput(),
>                     'password':PasswordInput(),
>                     'usertype':Select(choices=(("t1","type1"),
> ("t2","type2"))),
>                    }
>
> The form comes up as i wanted it to, but when i login it gives a
> validation error saying "user with this name already exists".
> I think its "form.is_valid()" checking "primary key" constraint,
> thinking i'm trying to write into the table. :(
> I cant remove the "primary key" constraint on "username" is there a
> way around this problem..

Why do you want a modelform though? The usual reason is to allow you
to add users or edit existing ones - since you don't supply an
existing user when instantiating the form, Django assumes you want to
create a new one, hence the error. But what are you gaining by using
the modelform here? It seems to me, nothing at all. Instead of
subclassing modelform, setting the model, and defining the widgets,
you might as well just use a normal form and define the fields
directly.
--
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: Django feeds sometimes generate AttributeError: 'LatestStripsByStripConfig' object has no attribute '__name __'

2010-11-25 Thread marty3d
It's 1.2.3. I have two ideas, either it could be the cache (started
using filesystem cache a week ago) or I'm using a stupid query for
returning the queryset (aka database performance issue).

Have anyone heard of caching messing with the feeds system?

/Martin

On Nov 25, 3:42 pm, Łukasz Rekucki  wrote:
> Well, something must have changed if you didn't had the problem
> before. What version of Django are you running ?
>
> On 25 November 2010 15:38, marty3d  wrote:
>
>
>
> > Hi!
>
> > My site have started to behave a little weird.
>
> > Lately, I get two or three errors per day, saying:
> > Traceback (most recent call last):
>
> >  File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
> > packages/django/core/handlers/base.py", line 95, in get_response
> >   response = middleware_method(request, callback, callback_args,
> > callback_kwargs)
>
> >  File "/home/mistalaba/.virtualenvs/production/lib/python2.5/site-
> > packages/django/middleware/doc.py", line 18, in process_view
> >   response['X-View'] = "%s.%s" % (view_func.__module__,
> > view_func.__name__)
>
> > AttributeError: 'LatestStripsByStripConfig' object has no attribute
> > '__name__'
>
> > I don't know why this is appearing all of a sudden, I haven't changed
> > the code, but I don't know where to start debugging this.
>
> > Here is my feeds.py, rather straightforward:
> > from django.contrib.syndication.views import Feed
> > from django.shortcuts import get_object_or_404
>
> > from strip.models import StripConfig, Strip
>
> > class LatestStripsByStripConfig(Feed):
> >    #__name__ = 'LatestStripsByStripConfig'
> >    description_template = 'feeds/latest_description.html'
>
> >    def get_object(self, request, stripconfig):
> >        return get_object_or_404(StripConfig, slug=stripconfig)
>
> >    def title(self, obj):
> >        return "Scandinavian Comics RSS feed for %s" % obj.strip_name
>
> >    def link(self, obj):
> >        return "%s?utm_source=feed&utm_medium=%s" %
> > (obj.get_absolute_url(), obj.strip_name)
>
> >    def description(self, obj):
> >        return "The latest %s comic strips. See more at
> >http://www.scandinavian-comics.com/strips/"; % obj.strip_name
>
> >    def items(self, obj):
> >        return
> > Strip.objects.filter(strip_config__slug=obj.slug).order_by('-date')[:
> > 10]
>
> >    def item_link(self, item):
> >        return "%s?utm_source=feed&utm_medium=%s&utm_campaign=%s" %
> > (item.get_absolute_url(), item.strip_config, item)
>
> > Does anyone have some wise suggestions? I would really appreciate it!
> > Thank you!
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: One-to-One relation with abstract classes

2010-11-25 Thread akaariai
On Nov 25, 12:42 pm, Clemens Wältken  wrote:
> Hey everyone!
> Iam new to this mailinglist and django + python in general.
> Yesterday I came up with a pretty complex question concerning abstract
> classes and relations.
> I have modeled the following classes:
>
>      Question
> /Answer
> /YesNoAnswer
>          FreeAnswer
>
> Answer should be abstract (note the italic text;) and has a one-to-one
> relation to question.
> In django both directions of this relation are navigable (by default)
> and this is intended, BUT by adding more concrete classes of Answer i
> automaticly create new fields in Question, like yesnoanswer and
> freeanswer and maybe many more. This kindof breaks the one-to-one
> relationship. In an ideal world id like to access the concrete Answer by
> calling Question.answer, i therefore wrote the kinda handy method
> getAnswer() to emulate this behavior. Is there a more elegant way to do
> this? Did i miss something in the django documentation? (Note that
> setting the related_name wont do the trick)

I am afraid that there is no easier way to do this. If I understand
the code correctly, what is happening is that each question can have
multiple answers, but a single one of any given type. So, there is
nothing in Django (or in the DB) restricting each question to have
just one answer. If you keep this data model, then it would be good to
add a db check or at least check on question.save() so that each
question can have just a single answer defined.

This could be modeled also in one of the following ways:
 - There is just one Answer model, with two fields: value and type.
Value could be free text, for YesNoAnswer 'yes' or 'no', and type
would be 'yesnoanswer'. This is problematic, since if you want to have
for example DateAnswer, then for efficient lookups (for example
answer__lte=datetime.date.today()), you would need to write custom SQL
so that you can cast the value to proper type.
 - The other possible way is to have one single big answer class with
a field for each type of possible answer. The type of the answer is
defined by which field is not null. This is the way I would model
this, as there is just one field with non-null answer, the extra null
fields consume next to nothing (just one bit per field) in the DB.

Also, why do you need to separate the answer model from the question?
Wouldn't it be best to have the answer directly in the question?

 - Anssi Kääriäinen

-- 
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.



how to do Query profiling of views called from AJAX calls?

2010-11-25 Thread ydjango
Django debug and django debug tool bar are not capturing the django
ORM calls made from the views which are called via AJAX calls in the
page . Is there any way to profile these sqls and times ?

-- 
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: One-to-One relation with abstract classes

2010-11-25 Thread Marc Aymerich
On Thu, Nov 25, 2010 at 11:42 AM, Clemens Wältken wrote:

>  Hey everyone!
> Iam new to this mailinglist and django + python in general.
> Yesterday I came up with a pretty complex question concerning abstract
> classes and relations.
> I have modeled the following classes:
>
> Question
> *Answer
> *YesNoAnswer
> FreeAnswer
>
> Answer should be abstract (note the italic text;) and has a one-to-one
> relation to question.
> In django both directions of this relation are navigable (by default) and
> this is intended, BUT by adding more concrete classes of Answer i
> automaticly create new fields in Question, like yesnoanswer and freeanswer
> and maybe many more. This kindof breaks the one-to-one relationship. In an
> ideal world id like to access the concrete Answer by calling
> Question.answer, i therefore wrote the kinda handy method getAnswer() to
> emulate this behavior. Is there a more elegant way to do this? Did i miss
> something in the django documentation? (Note that setting the related_name
> wont do the trick)
> Another thing is that the getAnswer method somehow breaks autocompletion in
> my iPython shell, but that's just a minor issue.
>
>
> ---
>
> class Question(models.Model):
> text = models.CharField(max_length=500)
> def __unicode__(self):
> return self.text
>
> def getAnswer(self):
> for c in Antwort.__class__.__subclasses__(Answer):
> try:
> return self.__getattribute__(c.__name__.lower())
> except:
> continue
> return None
>
>
In django you can get a good model introspection with _meta attribute.

>>> dir(self._meta)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_field_cache',
'_field_name_cache', '_fields', '_fill_fields_cache', '_fill_m2m_cache',
'_fill_related_many_to_many_cache', '_fill_related_objects_cache',
'_join_cache', '_m2m_cache', '_many_to_many', '_name_map', '_prepare',
'_related_many_to_many_cache', '_related_objects_cache', 'abstract',
'abstract_managers', 'add_field', 'add_virtual_field', 'admin', 'app_label',
'auto_created', 'auto_field', 'concrete_managers', 'contribute_to_class',
'db_table', 'db_tablespace', 'duplicate_targets', 'fields',
'get_add_permission', 'get_all_field_names',
'get_all_related_m2m_objects_with_model',
'get_all_related_many_to_many_objects', 'get_all_related_objects',
'get_all_related_objects_with_model', 'get_ancestor_link', 'get_base_chain',
'get_change_permission', 'get_delete_permission', 'get_field',
'get_field_by_name', 'get_fields_with_model', 'get_latest_by',
'get_m2m_with_model', 'get_ordered_objects', 'get_parent_list',
'has_auto_field', 'init_name_map', 'installed', 'local_fields',
'local_many_to_many', 'managed', 'many_to_many', 'module_name',
'object_name', 'order_with_respect_to', 'ordering', 'parents',
'permissions', 'pk', 'pk_index', 'proxy', 'proxy_for_model', 'setup_pk',
'setup_proxy', 'unique_together', 'verbose_name', 'verbose_name_plural',
'verbose_name_raw', 'virtual_fields']

Maybe you're interested
on: get_all_related_objects, object_name, many_to_many, etc...

-- 
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.



Weird problem after schema change

2010-11-25 Thread Chris Tandiono
Hi,

I'm using sqlite3 and django-evolution (and sometimes manual ALTER TABLE 
commands) for this website I'm making. Recently I added a new date field to one 
of my models, but it's not showing up in the admin interface. (I'm also having 
a problem in which the admin interface is taking taking a long time to load, 
but I think that's because my model has a ManyToMany field to a model with a 
lot of rows in the table.) How can I get the date field to show up in the admin 
interface?

Thanks,
Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Weird problem after schema change

2010-11-25 Thread Venkatraman S
On Fri, Nov 26, 2010 at 6:30 AM, Chris Tandiono wrote:

> How can I get the date field to show up in the admin interface?
>

Couple of checks:
- have you defined any custom forms for admin?
- Do the field names match properly?

A good practice generally is : do a 'sqlall' before you make the change in
your models.py and then again do the same after mod'ing your models.py file.
Do a diff between the two output sqlall files.

$python manage.py sqlall > before.txt
$vim ...models.py
$python manage.py sqlall > after.txt

-V-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 ticket tracking

2010-11-25 Thread Kenneth Gonsalves
On Thu, 2010-11-25 at 11:54 -0500, Karen Tracey wrote:
> (I used those session setting for a long time before I ever created a
> login,
> but that was years ago now. I assume it still works to avoid the spam
> filter.) 

I remember setting it about 5 years back - never had any problem since
then
-- 
regards
Kenneth Gonsalves

-- 
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.