Re: Multi-table inheritance with parent that can be null?
Ok. Everything clear then! Thank you! On 29 jun, 12:36, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-06-29 at 02:55 -0700, zenx wrote: > > Can you make a model that inherits from another model with multi-table > > inheritance and that can have a null parent? Or should do that always > > with OneToOneFIeld(null=True) ? > > No. The assumption is that the parent link will always be non-null. > After all, inheritance is saying you have an "is-a" relationship and it > doesn't really make sense to say "foo is-a nothing". If the "parent" can > be null, it's more of an attribute than an ancestor ("has-a", not > "is-a"). > > Regards, > Malcolm > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multi-table inheritance with parent that can be null?
Can you make a model that inherits from another model with multi-table inheritance and that can have a null parent? Or should do that always with OneToOneFIeld(null=True) ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: url template tag problem
Thanks Malcom, I changed the views function name but still got the same error so I don't know if it's a bug. I will try to take a closer look at it, but I really don't know why this may happen. Does anybody else has an idea? Thank you, Regards, A Mele On 30 jul, 22:28, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2007-07-30 at 19:28 +, zenx wrote: > > Hi, > > > I get the following error when trying to use the {% url %} > > templatetag. I have read the documentation several times but cannot > > understand where is the problem: > > > AttributeError at /c/albums/wonderful-world/ > > 'str' object has no attribute 'callback' > > > My urls.py: > > urlpatterns = patterns('', > > url(r'^artists/(?P[-\w]+)/$', view_artist, name='view- > > artist'), > > > > > My template: > > ... > > {% url view-artist slug=album.artist.slug %} > > ... > > > I have tried also {% url view-artist album.artist.slug %} but get > > still the same error :( > > Any ideas why this might happen? > > Almost certainly I bug. I suspect the problem is caused by your view > functions name and the url pattern's name being the same. Change the > name string to something else for the time being. And open a ticket > about this so that we don't lose track of it (I'm not in a position to > be able to fix it right at the moment -- about to run out of battery > power). > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
url template tag problem
Hi, I get the following error when trying to use the {% url %} templatetag. I have read the documentation several times but cannot understand where is the problem: AttributeError at /c/albums/wonderful-world/ 'str' object has no attribute 'callback' My urls.py: urlpatterns = patterns('', url(r'^artists/(?P[-\w]+)/$', view_artist, name='view- artist'), My template: ... {% url view-artist slug=album.artist.slug %} ... I have tried also {% url view-artist album.artist.slug %} but get still the same error :( Any ideas why this might happen? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
accessing request attributes in templatetags?
I know you can access request attributes in views, but how to access for example request.user or request.META['REMOTE_ADDR'] in templatetags? I have tried it several ways but really don't know how to do 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: saving many2many relations
Thank you Rajesh, I didn't knew that. I will try your solution. Thanks! On 11 jul, 23:16, RajeshD <[EMAIL PROTECTED]> wrote: > Hi, > > > Anyone knows where the problem is? > > If you are using the Admin app to populate tags then the automatic > manipulators first call Receta.save() followed by setting the models > M2M field. This wipes out your changes to etiquetas inside > Receta.save() > > One solution is to add get_tags and set_tags methods to Receta and do > a lazy initialization of your M2M field i.e. if get_tags finds that > self.etiquetas.all() is empty, it first populates self.etiquetas. > Then, for brownie points, wrap the get_tags and set_tags methods > around a property so you can do straight assignments. > > -Rajesh --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: saving many2many relations
Thank you Collin, I tried that before posting in this group but the same thing happened: I get no errors when saving but Tags still remain not asociated with Receta. class Receta(models.Model): def save(self): from django.template.defaultfilters import slugify tags = self.etiquetas_text.split(',') super(Receta, self).save() for tag in tags: etiq, created = Tag.objects.get_or_create(nombre=tag,slug=slugify(tag)) self.etiquetas.add(etiq) Anyone knows where the problem is? Thanks. On 11 jul, 01:06, Collin Grady <[EMAIL PROTECTED]> wrote: > A ManyToManyField is not a list to be replaced - add the new tags > directly to etiquetas using the .add() method on it. > > On Jul 10, 9:34 am, zenx <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I would like to get a list of tags separated by a comma and be able to > > save them as related objects for the current object. Currently I have > > this code. When saving a Receta object it creates the tags objects if > > they doesn't exist yet and it should save the relations between Tags > > and Receta, but they are not saved. The code doesn't give any errors > > but the Tag objects are not linked to the Receta object after saving > > it. > > > Any ideas why this happens? Thank you!!! > > > class Tag(models.Model): > > nombre = models.CharField(maxlength=20) > > slug = models.SlugField(prepopulate_from=("nombre",),unique=True) > > > class Receta(models.Model): > > user = models.ForeignKey(User) > > nombre = models.CharField(maxlength=50) > > slug = models.SlugField(prepopulate_from=("nombre",),unique=True) > > etiquetas = > > models.ManyToManyField(Tag,related_name='recetas',blank=True) > > tags_text = models.CharField(maxlength=150) > > > def save(self): > > from django.template.defaultfilters import slugify > > tags = self.tags_text.split(',') > > super(Receta, self).save() > > etiquetas_new = [] > > for tag in tags: > > etiq, created = > > Tag.objects.get_or_create(nombre=tag,slug=slugify(tag)) > > etiquetas_new.append(etiq) > > self.etiquetas = etiquetas_new --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
saving many2many relations
Hi, I would like to get a list of tags separated by a comma and be able to save them as related objects for the current object. Currently I have this code. When saving a Receta object it creates the tags objects if they doesn't exist yet and it should save the relations between Tags and Receta, but they are not saved. The code doesn't give any errors but the Tag objects are not linked to the Receta object after saving it. Any ideas why this happens? Thank you!!! class Tag(models.Model): nombre = models.CharField(maxlength=20) slug = models.SlugField(prepopulate_from=("nombre",),unique=True) class Receta(models.Model): user = models.ForeignKey(User) nombre = models.CharField(maxlength=50) slug = models.SlugField(prepopulate_from=("nombre",),unique=True) etiquetas = models.ManyToManyField(Tag,related_name='recetas',blank=True) tags_text = models.CharField(maxlength=150) def save(self): from django.template.defaultfilters import slugify tags = self.tags_text.split(',') super(Receta, self).save() etiquetas_new = [] for tag in tags: etiq, created = Tag.objects.get_or_create(nombre=tag,slug=slugify(tag)) etiquetas_new.append(etiq) self.etiquetas = etiquetas_new --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: User profile views - Does something like this make sense?
Thank you Gábor! I will make "clear_old" a static method. thanks!!! On 18 jun, 15:27, Gábor Farkas <[EMAIL PROTECTED]> wrote: > zenx wrote: > > I want to show the user the latest users that have seen his profile. > > So everytime a logged user views another user's profile a ProfieView > > object is stored in the database (or the date is updated if the user > > that is viewing the profile has already viewed it before). I know this > > can make the database grow too much, so I think I can run a cron > > script daily that deletes all profile views older than a week (see > > clear_old method). I don't know if the code is 100% correct, but is > > the concept ok? Does it make sense to add a new object to the database > > everytime another user views a profile? > > > class ProfileViews(models.Model): > > user = models.ForeignKey(User,related_name='latest_profile_views') > > viewer = models.ForeignKey(User) > > date = models.DateTimeField() > > > def clear_old(self): > > d = datetime.now()-timedelta(weeks=1) > > p = ProfileViews.objects.filter(date__lte=d) > > p.delete() > > i think this approach makes sense. > > the only change i would recommend is to make "clear_old" into a static > method. > > gabor --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User profile views - Does something like this make sense?
I want to show the user the latest users that have seen his profile. So everytime a logged user views another user's profile a ProfieView object is stored in the database (or the date is updated if the user that is viewing the profile has already viewed it before). I know this can make the database grow too much, so I think I can run a cron script daily that deletes all profile views older than a week (see clear_old method). I don't know if the code is 100% correct, but is the concept ok? Does it make sense to add a new object to the database everytime another user views a profile? class ProfileViews(models.Model): user = models.ForeignKey(User,related_name='latest_profile_views') viewer = models.ForeignKey(User) date = models.DateTimeField() def clear_old(self): d = datetime.now()-timedelta(weeks=1) p = ProfileViews.objects.filter(date__lte=d) p.delete() --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin filter change_list rows
Thank you Picio, that was very useful. I will try it :) On 1 mar, 09:40, Picio <[EMAIL PROTECTED]> wrote: > You can do It with custom Managers. This was my way to have list > filtered by user, but maybe It's not your case. Depending on the > deisgn of your project, may be It's better > to build a custom view inside the admin (as the djangobook chapter 18 > speaks). > Anyway I do It this way: > > 1 - store the user id taken from a middleware from the superguru > lukeplanthttp://lukeplant.me.uk/blog.php?id=1107301634 > > 2 - create a custom manager for the class you want the change-list page will > be > filtered that override the get_query_set(), this is less or more mine: > > class myCustomizedMan(models.Manager): > def get_query_set(self): > userid=threadlocals.get_current_user().id > return > super(myCustomizedMan,self).get_query_set().filter(your_user__id__exact=userid) > > 3 - I don't know if this problem still occur in 0.95.1 but in 0.95 If > you want to use a custom manager you have to say it inside the admin class: > > class Admin: > ... > bla bla bla filter, list_display whatever you want > ... > manager = myCustomizedMan() > > This was my little hack to have rows filtered by user. This way, people can't > display other users rows, inside the admin change-list page. > > Please consider that every time you achieve to customize the admin, > other new things come up and this hacking way never end. Django 1.0 > will solve this admin > customization issue with the new Admin class. > So IMHO: > 1) try your custom views instead > 2) try to customize the admin via chapter 18 of the djangobook > 3) try my little tric (based on the superduperguruLukeplant great hack) > 4) wait for the new Admin Class (maybe 0.96 will come soon) > > Bye > Picio > > 2007/3/1, zenx <[EMAIL PROTECTED]>: > > > > > Hi, > > > How could I filter the results of my admin change_list page. I know I > > can extend the change_list template but that doesn't allow me to > > filter the results. Is there some easy way to do that? > > > 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin filter change_list rows
Hi, How could I filter the results of my admin change_list page. I know I can extend the change_list template but that doesn't allow me to filter the results. Is there some easy way to do that? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django slows file uploads?
I have become a little bit disappointed while reading this: http://programming.reddit.com/info/ngua/comments "I have tested numerous files, and an excel file which takes 5 seconds to upload in Rails or another Python framework (like Pylons), will take over 20 seconds to upload in Django, mainly because of the parsing Django does on the file that no other frameworks do." Is django's way to handle file uploads really so bad? anybody knows if it will it be improved? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic relations in admin proposal
It's not my code, just took a look at it and found it useful. Thank you for looking at it! zenx --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Generic relations in admin proposal
Hi, After finding a good solution for generic relations in admin: http://net-x.org/weblog/2006/nov/29/django-generic-relations-made-easier/ I think that it should be implemented in the admin app of the django development version. What do you think about it? Want django developers to take the app as basis for generic relations in admin? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GenericForeignKey
Now it is!! http://net-x.org/media/GenericRelation-0.1.zip Rob Slotboom ha escrito: > > paulh, take a look at > > thishttp://net-x.org/weblog/2006/nov/29/django-generic-relations-made-eas... > > Hi Antoni, > > Seems interesting but the code isn't yet available I suppose... > > 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GenericForeignKey
paulh, take a look at this http://net-x.org/weblog/2006/nov/29/django-generic-relations-made-easier/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Saving info about viewed tags
Hi, I have an Objects Model and a Tags Model with a M2M relationship between them. I want to update info about the tags of the object visited by the user updating it everytime the user requests an Object. Is it a crazy idea? I want to know wich tags are the most viewed by the user and wich are the most recent he has view so that I can recommend him Objects that have also such tags (objects that are related to the ones he is interested in). This is my main idea how the models should be: === class MyObject(models.Model): tags = models.ManyToManyField(Tag) etc. class Tag(models.Model): etc... class RelationModel(models.Model): my_object = models.ForeignKey(MyObject) tag = models.ForeignKey(Tag) times_viewed = models.PositiveIntegerField() latest_view= models.DateTimeField() Problems I see: === - Lets say I have 30 tags for each object, I need to create_or_update 30 rows everytime a user requests an object. That could be a bottleneck :( - The relation table can be very big: 100.000 users x 2.000 tags each user = 200.000.000 rows in the relation table I should limit it to lets say 50 tags per user and in each update overwrite the less viewed and older tags with the new ones. -> more updates on every request :S - Is this the better way to do what I want to do? Any ideas? Thank you for your 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generating slug for words with accents
Spanish info: á é í ó úshould be a e i o u ü should be u ñ should be n I think that's everything in spanish ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
stats for object views
Hi, I have created a stats field (PositiveIntegerField) in my objects and I want to use it for saving how many times the object has been showed to visitors but I don't want to make a database request everytime an object is viewed due to performance issues. I have seen http://code.djangoproject.com/wiki/ProfilingDjango and I think I could save a profile for each url so I could use a cron job that executes a python script every 30min that updates the objects views in the database with the information of the profiles files. Is this the better way to do it? How have you dealt with this type of problems? Any suggestions? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
generic views serialization support (json, xml, etc.)
Hi, are there any plans to add serialization support to generic views? I think it won't be difficult to implement it because generic views are already programmed and they should only get one extra parameter to know which type of document they have to return (html (default), xml, json). It's just remembering what James Bennett said in this ticket: http://code.djangoproject.com/ticket/2553 I think that would be very useful for ajax apps with the advantage that it doesn't bind you to a specific ajax framework (like rails does). 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django color picker -- ColorField?
It would be cool if the javascript widget also displayed the hexadecimal color (like #FF) calculating it real time from the RGB selected color. It will be also interesting if people could get the RGB, hex, etc. color by different methods (not only rgb). --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: getting max and min
thank you all! I will do it with raw SQL . thanks for the code. I hope SQLAlchemy will be implemented soon in django. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django Hosting
It's not UK based but I have hosted some projects in hub-hub.com and I am satisfied with them. It's not super cheap but I think it's ok. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: getting max and min
hi, just tried this but doesn't work: q = ArtistaTag.objects.all() nums=[''] for tag in q: num = tag.artista_set.count() nums.append(num) max_art = max(nums) min_art = min(nums) i get a TypeError unsupported operand type(s) for -: 'str' and 'long' :( --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
getting max and min
I want to get the maximum and the minimum values of various numbers. Is the following method the best way to do it? for tag in q: num = tag.artista_set.count() if num_ant: if num < num_ant: min_art = num else: num_ant = num if num > max_art: max_art = num 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: templatetags: returning more information of every object in a list of objects (not only the objects)
thanks! just tried that way and everythings works. Thank you, Malcolm! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
templatetags: returning more information of every object in a list of objects (not only the objects)
Hi, I have a templatetag that returns a lists of objects. The problem is I want to include another information for every object: I want to include the number of related objects for every object of a ManyToMany relationship. The model ArtistaTag has a ManyToMany relationship with Artistas. So I use: tags=[''] nums=[''] q = ArtistaTag.objects.all() for tag in q: num = tag.artista_set.count() if num >= 1: tags.append(tag) nums.append(num) context['lista_tags'] = tags context['nums'] = nums return '' So that I become 2 lists, one with the objects (tags) and the other with the number of related objects (nums) but I don't know if this is the right way to do that an more important: I don't know how to get the number of every object in each object iteration in my template: {% for tag in lista_tags %} {{ tag.name }} how to get the num for this tag? I don't know if you understand me, please send any comments and I will try to clarify my problem. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
file extension validator
Hi, I want to make a filefield that only allows to upload mp3 files. I have added the following code to my model: def _manipulator_validate_filefield(self,field_data,all_data): if not self.archivo.endswith(".mp3"): raise validators.ValidationError, 'Please select an mp3 file.' I thought that was enought to validate the file but it doesn't validate anything when saving a new object, so what else should I do? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: urls and generic views with 2 slugfields
I will take a look at 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
urls and generic views with 2 slugfields
Hi, I've got 3 models: Artist, Album and Song. For getting an artist info I use: (r'^artists/(?P[-\w]+)/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, slug_field='identificador')), I want an url like www.mysite.com/artists/black_eye_peas/albums/album_name for getting all songs of that album that belongs to that artist. how could I do that? problem: it contains 2 slugfields 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Project level template tags?
OK. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Project level template tags?
Hi, I was wondering if it was possible to create project level template tags that can be called by any app template. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Easy thumbs in your models
you're right, that's better. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Easy thumbs in your models
In delete function use: super(MyClass, self).delete() instead of super(Artista, self).delete(). I think everything else is ok. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Easy thumbs in your models
I needed to make this and I hope it helps some people there. Features: - Generate thumbs from ImageFields when creating the models (file.jpg -> thumbnail saved as: file.thumbnail.jpg) - Showing thumbs in admin - Deleting thumbs when deleting the object In your models.py: from PIL import Image import glob, os thumb_size = 90, 90 class MyClass(models.Model): foto = models.ImageField(upload_to='my_photos/',blank=True) def save(self): file_path = self.get_foto_filename() # is there a photo? if (file_path): file, ext = os.path.splitext(file_path) im = Image.open(file_path) # thanks to PIL ;) im.thumbnail(thumb_size, Image.ANTIALIAS) # save thumbnail im.save(file + ".thumbnail.jpg", "JPEG") super(MyClass, self).save() def delete(self): file_path = self.get_foto_filename() # There's is a file? if (file_path): file, ext = os.path.splitext(file_path) thumb = file + ".thumbnail.jpg" # if there is a thumb we delete it if(thumb): os.remove(thumb) super(Artista, self).delete() def show_thumb(self): # get the url of the file file_path = self.get_foto_url() # add .thumbnail between file and extension file, ext = os.path.splitext(file_path) file = file + ".thumbnail.jpg" if(file_path): return "" % (file_path,file) mostrar_thumb.allow_tags = True mostrar_thumb.short_description='Foto' class Admin: list_display = ('show_thumb',) == That's all. If you make any improvements let me know 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SlugField is not unique?
Hi Gábor, I think it's just for making it more flexibile, but in the most cases you will use unique=True in your SlugFields. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Error always when deleting objects with ManyToMany (self) relationships
Nop, still doesn't work with filter_interface=models.HORIZONTAL. But it worked a couple of times. I will take a further look at 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Error always when deleting objects with ManyToMany (self) relationships
Hi Malcom, I have played a little around it and it seems to work ok adding filter_interface=models.HORIZONTAL to the Field. Here is the ticket I've created: http://code.djangoproject.com/ticket/2828#preview 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Error always when deleting objects with ManyToMany (self) relationships
Hi, I get always the following error when deleting objects with ManyToMany(self) relationships in the admin. Have tried with different models and always getting the same error. Doesn't the admin interface support ManyToMany relationships with the same table? TypeError at /admin/person/person/2/delete/ getattr(): attribute name must be string This is the model: = class Person(models.Model): name = models.CharField(maxlength=20) friends = models.ManyToManyField('self',blank=True) idols = models.ManyToManyField('self', symmetrical=False, related_name='stalkers',blank=True) def __str__(self): return self.name class Admin: pass --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
error when deleting model with ManyToManyField
TypeError at /admin/artistas/artista/asdf/delete/ getattr(): attribute name must be string this is the many to many field. when I delete it from the model everything works well but when that field is in the model i get the type error. artistas_relacionados = models.ManyToManyField('self',blank=True,related_name='artistas_rel') Any ideas why this can be? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Cannot have multiple projects running
Hi! I've set up django on dreamhost as seen here (http://www2.jeffcroft.com/2006/may/11/django-dreamhost/). Everything works ok with one project, but when I create another project and add another sub-domain for it following all the steps as shown on that site my browser doesn't load that sub-domain. It just stays "loading..." all the time. Any ideas why this is happening? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Uploading.
thanks for the tutorial!!! I wil take a look at 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Confirmation email during user registration?
Iwan, take a look at this too: http://feh.holsman.net/articles/2006/04/30/double-opt-in-user-registration-for-django http://feh.holsman.net/articles/2005/11/20/user-registration Instead of requiring a verification e-mail, it firsts sends the user an e-mail that includes a link for continuing the registration, as LJWorld.com does. Hope it helps ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
admin and dates...
Lets see if someone has already dealt with this problem and can help me: I want to administer appointments in admin. I have two classes: === class Client(models.Model): name = models.CharField(maxlength=30) company = models.CharField(maxlength=50) class Appointment(models.Model): client = models.ForeignKey(Client,raw_id_admin=True) when = models.DateField(core=True) hour = models.TimeField(core=True) === There is a ManyToOne relationship: I can make many appointments with every client and each appointment belongs only to one client. The problem is I cannot make an appointment with a client the same date and same time I've planned another appointment before. So I've got 2 troubles: - When creating a new appointment showing only available dates/times for selection. (perhaps with AJAX when selecting a date showing only available times for that date? but... how?) - In the appointments list view showing available days for directly adding an appointment that day (something like a timetable?) Has anyone dealt with appointments in django admin? how? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django Books
voted too! ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: AJAXWidgetComboBox in admin?
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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django Books
Picio, sorry for the misunderstanding! You will find the links that Jeremy has posted very useful :D (PS: I'm from Spain) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django Books
Hi Picio, I don't know when it will be published, but a book is coming: http://www.amazon.com/gp/product/1590597257 It is written by Adrian Holovaty and Jacob Kaplan-Moss (django developers) and as far as I know it will be also avaible for free download as PDF :D --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django Books
And you can find the starting tutorial you are asking for here: http://www.djangoproject.com/documentation/ take a look at "installation guide" and "Tutorial: Writing your first Django app" --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: AJAXWidgetComboBox in admin?
Thanks Matthew!!! I'm anxious to look at the code :D --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: AJAXWidgetComboBox in admin?
Ok. Thank you 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
AJAXWidgetComboBox in admin?
Just wanted to know if there are any implementations of the AJAXWidgetComboBox for the ForeignKey relationship inputs in the admin forms (instead of using raw_id_admin=True) http://code.djangoproject.com/wiki/AJAXWidgetComboBox 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: upload files to another server
Thank you both!!! That's very helpful! I will read the howto carefully ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: my private django repository goes public
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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: upload files to another server
Thank you Jacob! If anybody can point me to any link about setting up NFS with Django I would be grateful. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: upload files to another server
Thank you! I will take a look at 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
upload files to another server
I was reading some django performance tips: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ One of them is: "Use a separate media server" But how could I upload files with Django FileField or ImageField to another webserver than the one using django? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: HTTPS access
Oh yes!!! Thank you Ian! I've search for more info about urllib2 and I have come to this: http://www.holovaty.com/blog/archive/2004/06/20/0242 It seems that Adrian had already created a python interface to Gmail using urllib2 :D Thank you for your help and thanks to Adrian, too! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
HTTPS access
"Ruby has different libraries that provide higher-level access to network protocols such as FTP, HTTP or HTTPS. This article shows the usage of net::http, net::https, open-uri and the rio library." (http://www.juretta.com/log/2006/08/13/ruby_net_http_and_open-uri/) I would like django to connect to gmail via HTTPS and get the contact list of a user. I used to do it with PHP+Curl. Is there a library in django like curl? 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---