Django book
I'm new on this group, so first of all... Hi to everybody! I'm a web developer, and I need to approach Django for a software project, so I would like to ask you an advice about the best book to read (in your opinion) in order to learn using this framework, given that: * I already have some experience on web applications' development with PHP MVC frameworks like Drupal; * I have some experience of Python (non-web) programming; * I'd prefer printed books. Thanks in advance for any answer. -- 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-taggit] Recording additional tagging metadata with the admin
Hi, I have a question about ``django-taggit`` and the admin site. I have written a custom intermediate model [1] for storing additional tagging metadata, i.e. the user doing the tagging and when the tagging happen: class TaggedItem(GenericTaggedItemBase, TaggedItemBase): tagger = models.ForeignKey(User, null=True, blank=True, editable=False) tagging_time = models.DateTimeField(null=True, auto_now_add=True) Then, I made a model taggable: class Foo(models.Model): # field defs tags = TaggableManager(through=TaggedItem, blank=True) Now when a ``Foo`` model instance is created/changed, I would like those additional tagging metadata to be filled with ``request.user`` and the current time. My question is: how can I achieve this behaviour ? I suppose I have to hook someway in the admin, but I don't know way. Thanks in advance for any answers. [1] http://readthedocs.org/docs/django-taggit/en/latest/custom_tagging.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
djangoadvent.com is down ?
Hi, some time ago I bookmarked some posts on http://djangoadvent.com that seemed very interesting to me; yesterday I wanted to read some of them, but I wasn't able to retrieve them. The website was unreacheable, and I was able to found a cached version of only a few of them. Do you know anything about it ? Can you point me to a mirror ? Thanks in advance for any answer. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: djangoadvent.com is down ?
On 07/28/2011 04:55 PM, Lorenzo Franceschini wrote: Hi, some time ago I bookmarked some posts on http://djangoadvent.com that seemed very interesting to me; yesterday I wanted to read some of them, but I wasn't able to retrieve them. The website was unreacheable, and I was able to found a cached version of only a few of them. Do you know anything about it ? Can you point me to a mirror ? I wasn't able to find the original articles, but at least I found their sources on this repo on GitHub: https://github.com/djangoadvent/djangoadvent-articles Just as a reference for anyone who may be interested in them ;-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: curious about model classes
On 03/03/2011 04:33 PM, bruno desthuilliers wrote: It has nothing to do with "looking cool" or anything like that. Using models.fields as class attributes in models class statement's body allow for the ORM to know what db fields and relations your table has - not what instance attributes a model instance will have. Well, not directly at least - of course the Model base case makes sure your instance will have corresponding instance attributes (for db fields), but note that these instance attributes are just plain python attributes, NOT the models.fields you defined at the class level. I have a question about this point. In one Django application I'm writing, I would like to programatically add some attributes to a model instance when it's retrieved from the database. I thought this would work: class Foo(models.Model): bar = models.CharField(max_length=10) def __init__(self, *args, **kwargs): super(Foo, self).__init__(self, *args, **kwargs) self.foobar = do_something(bar) f = Foo(bar='test') Until then, it's ok: the model instance 'f' is created and so the attribute f.foobar; but when I try to save the instance to the db f.save() Django fails with an obscure (for me) error: -- File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/base.py", line 458, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/base.py", line 520, in save_base manager.using(using).filter(pk=pk_val).exists())): File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/query.py", line 561, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/query.py", line 579, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1170, in add_q can_reuse=used_aliases, force_having=force_having) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1105, in add_filter connector) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/where.py", line 67, in add value = obj.prepare(lookup_type, value) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/sql/where.py", line 316, in prepare return self.field.get_prep_lookup(lookup_type, value) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 292, in get_prep_lookup return self.get_prep_value(value) File "/home/lorenzo/.virtualenvs/virgo/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 479, in get_prep_value return int(value) TypeError: int() argument must be a string or a number, not 'Foo' --- What's wrong with this approach ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.