doctest & abstract base class models

2008-09-01 Thread fgasperino
All, I have an abstract base class for which I'm wishing to write some in- line doctests. I have read ticket http://code.djangoproject.com/ticket/8108 which addresses it, but I'm hoping to find a work-around. In the snip below, I want to test the Base.__unicode__() method without writing a docte

Proxy meta ordering in admin

2009-07-23 Thread fgasperino
class MyModel (models.Model): name = models.CharField(...) class MyProxy (MyModel): class Meta: proxy = True ordering = ["name"] class MyAdmin (admin.ModelAdmin): pass admin.site.register(MyProxy, MyAdmin) The above example does not seem to honor the ordering field within the adm

Generic views: delete_object and post_delete_redirect

2009-06-16 Thread fgasperino
All, When creating a pluggable app, I've run across the need to use the django.views.generic.create_update.delete_object view. Below is a snippet of my URL patterns. from django.conf.urls.defaults import * from django.core.urlresolvers import reverse urlpatterns = patterns("", url(r"list/",

Inheriting from User, UserAdmin, and the Admin site

2009-12-11 Thread fgasperino
All, I have the following setup: --models.py -- from django.db import models from django.contrib.auth.models import User as DjangoUser class Business (models.Model): ... class Group (models.Model): business = models.ForeignKey(Business) ... class User (DjangoUser): group = models.Fore

Re: Inheriting from User, UserAdmin, and the Admin site

2009-12-12 Thread fgasperino
Looking into this a little deeper, it appears that from django.contrib.auth.admin.UserAdmin uses django.contrib.auth.models.User in the meta class. I've attempted to point this to my app's proxy model by inheriting here as well: -- forms.py -- from django.contrib.auth.forms import UserCreationFor

Re: Inheriting from User, UserAdmin, and the Admin site

2009-12-12 Thread fgasperino
Solved by the Manager adding django.contrib.auth.models.UserManager to the inherited User model. from django.db import models from django.contrib.auth.models import User as DjangoUser, UserManager as DjangoUserManager class User (DjangoUser): objects = DjangoUserManager() The admin site now

Adding extra data in annotate()

2010-11-30 Thread fgasperino
All, I'm attempting to consolidate many orm queries into one. My models: class Key (models.Model): name = models.CharField() class Value (models.Model): data = models.FloatField() timestamp = models.DateTimeField() key = models.ForeignKey(Key) Given a list of Key names, I am able to ann

Re: Adding extra data in annotate()

2010-11-30 Thread fgasperino
Ideally any proposed solution could also substitute the search for the newest timestamp via Max() to be the largest Value.data float with similar logic. Franco -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email t

Re: Adding extra data in annotate()

2010-11-30 Thread fgasperino
For reference, it looks like D.Rosman has already wrote about the same topic at http://blog.roseman.org.uk/. Franco -- 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 unsubscri

Re: Help! I'm thick! First formset generating AttributeError

2010-12-08 Thread fgasperino
While I haven't worked with formsets, this line doesn't look correct: formset = ClientFormSet(request.POST, request.FILES, queryset=Client.objects.get(pk=client_id)) mainly due to a parameter named queryset being passed a model object, instead of a queryset of model objects. It would seem that yo

Model Inheritance - best practice for templates?

2010-02-24 Thread fgasperino
All, Currently I'm working with the following 2 models: class A (models.Model): ... class B (A): somefield = ... I have a generic views with querysets defined as: url(r"A/view/(?P\d+)/$", "django.views.generic.list_detail.object_detail", dict(queryset = A.objects.all(), template_name =

Re: Model Inheritance - best practice for templates?

2010-02-24 Thread fgasperino
mis-clicked, continuing: @register.filter def A_get_B(instance):     if isinstance(instance, B):         return instance.b     try:         return instance.b     except B.DoesNotExist:         return None and lastly, the template: {% with a|A_get_B as b %} {% if b %} .. work with b {% endif