Variable value in template

2007-04-11 Thread Kai Kuehne
With this Team: {% for team in object.squad.team_set.all %} {% appearance_count_for_team team.id %} and class AppearanceCountForTeamNode(template.Node): def __init__(self, team_id): print team_id ... I get "team.id" printed out and not the id of the team. W

Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hi list, why can I add a record in the admin where the name field is empty, when the docs say: "primary_key=True implies blank=False, null=False and unique=True. Only one primary key is allowed on an object." My code: name = models.CharField(maxlength=255, primary_key=True, db_index=True) There

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hi, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > > Hi list, > > why can I add a record in the admin where the name field is empty, > > Because, as you wrote, blank and null are False? blank=False means that a blank field ISN'T allowed. Kai --~--~-~--~~~--

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hola, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > Sorry, I don't understand what you are asking.then.The > first paragraph of your message was: Second try: primary_key=True implies blank=True and null=True. This means that you cannot add an entry where the name (in my case) is empty.

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Argh, sorry... I made a mistake: primary_key implies blank=False and null=False. Now it should be correct. :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

Re: Primary key field can be empty

2007-04-25 Thread Kai Kuehne
Hi, On 4/25/07, Ramiro Morales <[EMAIL PROTECTED]> wrote: > Try adding blank=False explicitely because it works > at the admin UI level so it doesn't know about database > primary keys and such. I thoght "implies" means "automatically added". Well, I will try add it manually... seems like a bug,

Database design question

2007-04-25 Thread Kai Kuehne
Hello list, I have a question regarding general database design. Ok.. which method would you recommend, if you have a table with a field 'name' which values should be unique in the whole table? 1) use (implicit) id which is automatically added by django, as primary key and a 'name' field with "un

Re: Database design question

2007-04-25 Thread Kai Kuehne
Hi, On 4/25/07, Mike Caldwell <[EMAIL PROTECTED]> wrote: > I don't think there is a "right(tm)" way, but there are some things to > consider. A lot of people would argue that a unique characteristic makes a > very good primary key, I think I might be one of them. But, remember that > data refle

Re: Database design question

2007-04-25 Thread Kai Kuehne
A point that I missed was the speed. Is method 1) maybe faster than method 2? I think it could.. because in 1) there are only numbers stored as primary_key and not strings (which can be as long as 255 characters). Speed is one thing.. but is there any other difference between the two methods? Whi

Re: Database design question

2007-04-26 Thread Kai Kuehne
Hi Doug, On 4/26/07, Doug Van Horn <[EMAIL PROTECTED]> wrote: > [Links] > There's no harm in having unique columns in addition to your primary > key (as you describe). The nut of the problem around natural keys, > IMHO, is that the rules that make them natural keys today can change > such that t

Re: Primary key field can be empty

2007-04-26 Thread Kai Kuehne
Hi, On 4/26/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Wow .. there's been a lot of response to this without the answer > actually appearing: it's a bug! :-) > > Ticket #3774 is the relevant ticket. > > I'm very tempted to fix this by actually implementing the documented > behaviour, bec

How would you cache a view that will never change?

2007-10-25 Thread Kai Kuehne
Hi list, maybe I'm a bit confused (or tired) but how would you go and cache a view that will *never* change depending on a request on my application? If I read the manual right, I have to give a timeout to all the cache functions that are available. In my case I have a view that will never change

Re: How would you cache a view that will never change?

2007-10-26 Thread Kai Kuehne
Hi! On Oct 26, 2007, at 4:07 AM, [EMAIL PROTECTED] wrote: > >> maybe I'm a bit confused (or tired) but >> how would you go and cache a view that will *never* >> change depending on a request on my application? > > Is the output something difficult for the view to generate? No, it's just a massi

Calling model-functions in template

2006-12-02 Thread Kai Kuehne
Hello list! Is it possible to call functions of the model out of the template? Sorry, didn't find it in the docs. Example: {{ model.function() }} Thanks Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: Calling model-functions in template

2006-12-02 Thread Kai Kuehne
Hi, On 12/2/06, James Bennett <[EMAIL PROTECTED]> wrote: > Note that this has 'method', not 'method()' -- parentheses are not > used, and it is not possible to pass arguments to the method. This is > done because the template language is not meant to be a full > programming language; if you need

Re: Calling model-functions in template

2006-12-02 Thread Kai Kuehne
I must misunderstand something really basic here. Just look: Template: {{ movie.genres_title_list }} models.py: def genres_title_list(self, separator=', '): return separator.join([x.title for x in self.genres]) Prints nothing... idea anyone? Kai --~--~-~--~~

Re: Calling model-functions in template

2006-12-03 Thread Kai Kuehne
Hi, On 12/3/06, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > Kai Kuehne wrote: > [model.py] > > If I reconstruct the case correctly and `genres` is a relation to child > objects with ForeignKey to a Movie then `self.genres` by default should > look like `self.genre_set.a

Template extending problem

2006-12-09 Thread Kai Kuehne
Hi list! I've got a problem: settings.py: TEMPLATE_DIRS = ( '/home/kai/Projekte/kaikuehne/templates' ) home.html: {% extends "/blog/base" %} I get the following error: "Template '/blog/base' cannot be extended, because it doesn't exist" But, the file does exist: $ ls -l /home/

Re: Template extending problem

2006-12-09 Thread Kai Kuehne
Hi, On 12/9/06, mezhaka <[EMAIL PROTECTED]> wrote: > > try > {% extends "/blog/base.html" %} > instead of > {% extends "/blog/base" %} Doesn't work. Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django user

Re: Template extending problem

2006-12-09 Thread Kai Kuehne
Sorry, forget to paste the blog/base.html. So, here it is: {% load comments.comments %} http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> http://www.w3.org/1999/xhtml";> My django blog: {% block title %}Generic Page{% endblock %} {% block extrahead %}{%

Re: Template extending problem

2006-12-09 Thread Kai Kuehne
Hi Baurzhan, On 12/10/06, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > Hello Kai, > > On Sun, Dec 10, 2006 at 12:23:09AM +0100, Kai Kuehne wrote: > > > {% extends "/blog/base" %} > > Doesn't work. > > {% extends "blog/base.html

Re: Design Q: Foreign keys from object.values()

2007-01-10 Thread Kai Kuehne
Hi George, On 1/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > class Author (models.Model) : > name = CharField(maxlength=100) > class Story (models.Model) : > author = ForeignKey(Author) What about a relation, hm? :) Kai --~--~-~--~~~---~--~~ You re

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-20 Thread Kai Kuehne
Hi Nate, On 1/20/07, natebeaty <[EMAIL PROTECTED]> wrote: > blog_dict = { > 'queryset': Blog.objects.all(), > 'template_object_name': 'blog', > "extra_context" : { > "blog_month_list" : Blog.objects.dates("date_added", "month"), > "current_issue" : Issue.objects.latest

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-20 Thread Kai Kuehne
Hi, On 1/21/07, natebeaty <[EMAIL PROTECTED]> wrote: > Wait, can't you just use post.tags.all in your object_detail template > without any wrappers (for all tags related to a post)? Django will > auto-populate such a related list in a generic view: > > {% if post.tags.all %} >

Re: developing a new ajax website: places2go.org. some comments apreciated.

2007-02-07 Thread Kai Kuehne
Hey Pedro, On 1/10/07, pedro <[EMAIL PROTECTED]> wrote: > Hello guys, > > http://www.places2go.org: is a new site i'm developing, already > available in a beta version. Cool idea, but I don't like colors. Kai --~--~-~--~~~---~--~~ You received this message becau

Shuffled Model selection

2007-02-09 Thread Kai Kuehne
Hey! I wanted to select all models, but in random order: random.shuffle(Obj.objects.all()) This doesn't work, error message: TypeError: object does not support item assignment Anyony an idea in how to make it? (It's for a blogroll, if you wonder where it could be used.) Greetings :)

Re: Shuffled Model selection

2007-02-09 Thread Kai Kuehne
Sorry, I got it: all = Obj.objects.all() newlist = [x for x in all] random.shuffle(newlist) Not that beautiful, but it works. :) Greetings Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django use

Re: Shuffled Model selection

2007-02-09 Thread Kai Kuehne
Hi On 2/9/07, Brett Parker <[EMAIL PROTECTED]> wrote: > Err, why not use a random sort as... > > Obj.objects.order_by('?') > > ref: http://www.djangoproject.com/documentation/db_api/#order-by-fields Becasue I didn't know it (a good reason, I think). > Cheers, Thanks Brett! Kai --~--~-

Re: changing maxlength html attribute

2007-02-09 Thread Kai Kuehne
Btw, why is it called maxlength and in newforms max_length (or the other way around, not sure)? Shouldn't they be identcal? Greetings Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

<    1   2