It work:
Topic.objects.filter(pk__in=[comment.content_object.pk for comment in
Comment.objects.filter(user__exact = request.user)])
On Oct 6, 9:13 pm, "David.D" <dengyuanzh...@gmail.com> wrote:
> class Topic(models.Model):
> title = models.CharField(max_
class Topic(models.Model):
title = models.CharField(max_length=100)
body = models.TextField(_('body'), max_length=TEXT_MAX_LENGTH)
user = models.ForeignKey(User, related_name='topic_user',
editable=False)
...
I use 'django.contrib.comments' to reply a topic. How to get topics
My models all extend my custom model class which id is a CharField not
a PositiveIntegerField like the Django's default
django.db.models.Model .
So, when I try to add a vote, I got a ValueError:
invalid literal for int() with base 10: 'my-char-id'
Because the object_id field is defined like this
I hope to get this result:
34.000 --> 34
34.100 --> 34.1
34.120 --> 34.12
34.123 --> 34.123
But the output of floatformat filter is like this:
34.000|floatformat:"-3" --> 34
34.100|floatformat:"-3" --> 34.100
34.120|floatformat:"-3" --> 34.120
34.123|floatformat:"-3" --> 34.123
Thank
desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 13 sep, 18:20, "David.D" <dengyuanzh...@gmail.com> wrote:
>
> > In my template:
>
> > This is ok:
> > {{ my_list.2 }}
>
> > But it doesn't work:
> > {{ my_list.index }}
>
> &
In my template:
This is ok:
{{ my_list.2 }}
But it doesn't work:
{{ my_list.index }}
index is a context variable (index=2)
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
; along the way.
>
> - Paulo
>
> On Thu, Aug 5, 2010 at 8:52 AM, Daniel Roseman <dan...@roseman.org.uk>wrote:
>
>
>
> > On Aug 4, 7:27 pm, "David.D" <dengyuanzh...@gmail.com> wrote:
> > > I just wonder if there's some way requires
> @register.filter
> def class_name(value):
> return value.__class__.__name__
>
> On Aug 4, 11:13 am, "David.D" <dengyuanzh...@gmail.com> wrote:
>
>
>
> > There's no django's built-in way?
>
> > On Aug 4, 10:37 pm, Scott Gould <zi
There's no django's built-in way?
On Aug 4, 10:37 pm, Scott Gould <zinck...@gmail.com> wrote:
> How about writing a simple template tag that takes an object and
> returns object.__class__.__name__?
>
> On Aug 4, 10:20 am, "David.D" <dengyuanzh...@gmail.com> wr
I did it by adding this to my models:
def get_model_name(self):
return self.__class__.__name__
And it works
But I don't want to define the 'get_model_name' method in my model.
Is there a built-in way?
Thanks.
--
You received this message because you are
It work!
Thank you.
On Jul 4, 9:30 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Jul 4, 12:01 pm, "David.D" <dengyuanzh...@gmail.com> wrote:
>
> > i mean
> > i have a model instance m, and m has a field fd.
> > so i can wrote like this in te
i mean
i have a model instance m, and m has a field fd.
so i can wrote like this in template
{{ m.fd }}
but, when i got a string s = "fd"
how could i do the same as above?
thanks for any help...
--
You received this message because you are subscribed to the Google Groups
"Django users"
)
>
> #get comment for instance
> Comment.objects.for_model(Post.objects.get(id=1)).count()
>
> 2008/11/2 David.D <[EMAIL PROTECTED]>
>
>
>
> > I can get comment_count in templates:
>
> > {% get_comment_count for object as comment_count %}
>
> > But how to get it in my
I can get comment_count in templates:
{% get_comment_count for object as comment_count %}
But how to get it in my view?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group,
I made a mistake! I use 'extra_context=locals()' in my generic view.
Now no problem.
Thanks very much.
On Jun 9, 12:34 pm, "David.D" <[EMAIL PROTECTED]> wrote:
> If there are no parameters, it works fine in django.
> For example:
>
> def functionA(): # no para
(indata)
func() # no parameter
This will be fine. But it's not enough for my needs.
Thank you.
On Jun 8, 2:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> 2008/6/8 David.D <[EMAIL PROTECTED]>:
>
>
>
>
>
>
>
> > view.py
> >
view.py
=
def functionA(request):
...
return ...
def functionB(request):
return ...
callDict = {'functionA': functionA, 'functionB':functionB,...}
def myview(request, indata):
func = callDict.get(indata)
func(request)
indata is a
I worked! Thank you very much.
On Jun 3, 1:15 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 2, 2008 at 9:06 AM, David.D <[EMAIL PROTECTED]> wrote:
> > views.py
> > ==
> > def model_form(request, model_name):
> > form_class
Thanks. But I got
TypeError at /products/ModelA/
'module' object is not callable
On Jun 3, 1:12 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 2, 2008 at 10:06 AM, David.D <[EMAIL PROTECTED]> wrote:
>
> > In my "products" app:
>
In my "products" app:
models.py
class ModelA(models.Model):
...
class ModelB(models.Model):
...
class ModelC(models.Model):
...
...
class ModelAForm(ModelForm):
class Meta:
model = ModelA
class ModelBForm(ModelForm):
class Meta:
model = ModelB
If there are lots of child model, use hasattr() or capture exception
will not be good?
"add a type field to Person() and overide the save fields on Man and
Woman to set the type field correctly. " will be better?
On May 30, 10:38 pm, David Zhou <[EMAIL PROTECTED]> wrote:
> On May 30, 2008, at
21 matches
Mail list logo