Django Admin: Redirecting after save
Hello, I have a more complex dialog within the django admin, which requires a redirect to an intermediate page, when a certain model is saved. It seems as the django ModelAdmin does not provide any hooks for this purpose. I found a workarround here: http://joshourisman.com/2008/10/27/modifying-django-admin-redirects-after-adding-changing-and-deleting/ But it this doesnt work for me, as I definitvely need the id of the object that just has been saved. So what I need is: - after model save --> redirect to another view Any ideas? Thanks - Toni -- 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.
Optional GenricForeigKey: "null=True, blank=True" => unexpected keyword argument
Hello, I have a model that I want to have an optional generic relation to any other kind of model. content_type = models.ForeignKey(ContentType, null=True, blank=True) object_id = models.PositiveIntegerField(null=True, blank=True) content_object = generic.GenericForeignKey(null=True, blank=True) The problem is, that content_object does not accept "null=True, blank=True". I always run into an "unexpected keyword argument" exception. So any ideas how to make a generic FK optional?? 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with django tagging: how to add tags??
Hi there, I am using django tagging and have problems adding tags to an object. There are 2 methods that enable adding a tag: - add_tag() - update_tags() -- for tag in parse_inputs(form.cleaned_data['tags']): Tag.objects.add_tag(tag) --- This seems to work fine, but if I pass something like "Feature Recognition" (A tag containing 2 word) I get an AttributeError "multiple tags were given". In the docs under "Tag input" they say that | apple "ball cat" dog | results in these tags [apple], [ball cat], [dog]. So I tried to workaround this problem by using the update_tags method, but this just clears all existing and inserts the passed ones. So could someone please tell what I am doi9ng wrong, or how to add tags Thanks, toni --~--~-~--~~~---~--~~ 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: Django 1.0 and Stdimage does not work
Hi lapain, yes, this solved the TypeError, but now I am running into a "No such file or directory". I opened a new thread: http://groups.google.com/group/django-users/browse_thread/thread/b0d3e55398f2906d. Thanks for your answer. -Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to use Stdimage with Django 1.0
Hello, I am using Stdimage in combination with Django 1.0. Picture(models.Model) image = StdImageField(upload_to ='multimedia/pictures', null=True, size=(573, 441), thumbnail_size=(100, 100, True)) ... in my view I do this: picture = Picture(gallery = gallery, image = request.FILES['image'].name) picture.save() But when I do this I get an "No such File or directory". When I do something like this (which is the way you go using the django-built-in image field): picture = Picture(gallery = gallery, image = request.FILES['image'].name) filename = '%s_%s.jpg' % (str(gallery.content_object), picture.id) picture.image.save(filename, request.FILES['image'], save=True) ...then I run into a maximum recursion error. Please help me, and tell me waht I am doing wrong. Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to use Stdimage with Django 1.0
Hello, I am using Stdimage in combination with Django 1.0. Picture(models.Model) image = StdImageField(upload_to ='multimedia/pictures', null=True, size=(573, 441), thumbnail_size=(100, 100, True)) ... in my view I do this: picture = Picture(gallery = gallery, image = request.FILES['image'].name) picture.save() But when I do this I get an "No such File or directory". When I do something like this (which is the way you go using the django-built-in image field): picture = Picture(gallery = gallery, image = request.FILES['image'].name) filename = '%s_%s.jpg' % (str(gallery.content_object), picture.id) picture.image.save(filename, request.FILES['image'], save=True) ...then I run into a maximum recursion error. Please help me, and tell me waht I am doing wrong. Thanks, Toni --~--~-~--~~~---~--~~ 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 1.0 and Stdimage does not work
Hello, I am using Stdimage instead of the native models.ImageField to have scaling and thumbnail support. With the former 0.97 release Stdimage just worked perfect. Now I tried to use it with Django 1.0, and of course I also updated Stdimage to the newest svn-release. But when uploading an Image I run into trubble: I get an TypeError unsubscriptable object. Traceback: File "C:\Programme\Python24\lib\site-packages\django\core\handlers \base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "D:\projects\openContext\src\pictures\views.py" in add_picture 46. picture = Picture(gallery = gallery, image = request.FILES['image']) File "C:\Programme\Python24\lib\site-packages\django\db\models \base.py" in __init__ 266. signals.post_init.send(sender=self.__class__, instance=self) File "C:\Programme\Python24\lib\site-packages\django\dispatch \dispatcher.py" in send 148. response = receiver(signal=self, sender=sender, **named) File "C:\Programme\Python24\lib\site-packages\stdimage\fields.py" in _set_thumbnail 110. filename = self.generate_filename(instance, os.path.basename(getattr(instance, self.name).path)) File "C:\Programme\Python24\lib\site-packages\django\db\models\fields \files.py" in _get_path 49. return self.storage.path(self.name) File "C:\Programme\Python24\lib\site-packages\django\core\files \storage.py" in path 202. path = safe_join(self.location, name) File "C:\Programme\Python24\lib\site-packages\django\utils\_os.py" in safe_join 13. final_path = normcase(abspath(join(base, *paths))) File "C:\Programme\Python24\lib\ntpath.py" in join 67. elif isabs(b): File "C:\Programme\Python24\lib\ntpath.py" in isabs 53. s = splitdrive(s)[1] File "C:\Programme\Python24\lib\ntpath.py" in splitdrive 119. if p[1:2] == ':': Any ideas how to fix this bug, or better - what am I doing wrong? --~--~-~--~~~---~--~~ 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 1.0 and Stdimage does not work
Hello, I am using Stdimage instead of the native models.ImageField to have scaling and thumbnail support. With the former 0.97 release Stdimage just worked perfect. Now I tried to use it with Django 1.0, and of course I also updated Stdimage to the newest svn-release. But when uploading an Image I run into trubble: I get an TypeError unsubscriptable object. Traceback: File "C:\Programme\Python24\lib\site-packages\django\core\handlers \base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "D:\projects\openContext\src\pictures\views.py" in add_picture 46. picture = Picture(gallery = gallery, image = request.FILES['image']) File "C:\Programme\Python24\lib\site-packages\django\db\models \base.py" in __init__ 266. signals.post_init.send(sender=self.__class__, instance=self) File "C:\Programme\Python24\lib\site-packages\django\dispatch \dispatcher.py" in send 148. response = receiver(signal=self, sender=sender, **named) File "C:\Programme\Python24\lib\site-packages\stdimage\fields.py" in _set_thumbnail 110. filename = self.generate_filename(instance, os.path.basename(getattr(instance, self.name).path)) File "C:\Programme\Python24\lib\site-packages\django\db\models\fields \files.py" in _get_path 49. return self.storage.path(self.name) File "C:\Programme\Python24\lib\site-packages\django\core\files \storage.py" in path 202. path = safe_join(self.location, name) File "C:\Programme\Python24\lib\site-packages\django\utils\_os.py" in safe_join 13. final_path = normcase(abspath(join(base, *paths))) File "C:\Programme\Python24\lib\ntpath.py" in join 67. elif isabs(b): File "C:\Programme\Python24\lib\ntpath.py" in isabs 53. s = splitdrive(s)[1] File "C:\Programme\Python24\lib\ntpath.py" in splitdrive 119. if p[1:2] == ':': Any ideas how to fix this bug, or better - what am I doing wrong? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Authentication: user_passes_test() - issue
Hi, I my scenario users can only edit some model if thy are also the authors. With the permission_required_decorator this is not possible. So what about the user_passes_test-decorator. I want to do something like this: def user_can_edit(user, model): if user.is_authenticated and user == model.author: return True else: return False So the problem is, how do I pass the model? Is there a way to this, or do I have to write my own decorator? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Authentication: user_passes_test() - issue
Hi, I my scenario users can only edit some model if thy are also the authors. With the permission_required_decorator this is not possible. So what about the user_passes_test-decorator. I want to do something like this: def user_can_edit(user, model): if user.is_authenticated and user == model.author: return True else: return False So the problem is, how do I pass the model? Is there a way to this, or do I have to write my own decorator? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
problem with built-in login-view (Authentication)
Hello, I am trying to use djangos authentication system. Former I always did the login-stuff manually, but now I stumbled over the built-in authentication-functionality described in http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login. But when I am trying this I got : AttributeError at /accounts/login/ 'Manager' object has no attribute 'get_current' I the traceback the error is thrown in django\contrib\auth\views.py in login 34. if Site._meta.installed: 35. current_site = Site.objects.get_current() So I dont understand, because I dont have the Sites-subframework installed. any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ModelChoiceField - remove empty-value
Hello, I use a modelchoicefield and want to remove the entry that represents "no item selected"(--), because in my scenario I will only allow to select between existing entries. Is there a way to do this? Thanks, -Toni --~--~-~--~~~---~--~~ 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: ModelChoiceField and dynamic Querysets
This solved the problem: http://groups.google.com/group/django-users/browse_thread/thread/63c2058c7892f865 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ModelChoiceField and dynamic Querysets
With the ModelChoiceFiled you can represent relationships between models. So my form looks something like this: class MyForm(forms.Form): name = forms.CharField() trials = forms.ModelChoiceField(...) According to the documentation I have to pass the queryset to the modelchoicefield. But how can I do this: e.g. I want to pass somethiung like this: queryset = MyModel.objects.filter(a_fk = .., b_fk = null).exclude(...) How do I pass this to the trials formField? The filter lookup also takes some variables into account and in my forms.py I dont see a way to realize this, as I can not pass any arguments. How can I pass a dynamic generated queryset? 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 -~--~~~~--~~--~--~---
How to determine whether save() performs update or insert
Is there a way to determine whether the model´s save()-method performs an insert or an update? I want to do something like this: create modelA_Instance --> create modelB_Instance. So my plan is to do this in the save() from modelA. --~--~-~--~~~---~--~~ 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: getting max(field) with db-api
Oh thanks, I think I have overlooked it :-) On 2 Sep., 16:35, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Wiadomość napisana w dniu 2008-09-02, o godz. 16:23, przez mwebs: > > > > > > > Hello, > > > I want to perform a lookup an getting the object with the highest > > integer value. > > The Model looks something like this: > > > MyModel: > > name = > > number = models.PositiveIntegerField() > > > class Meta: > > ordering = [-number] > > > So I figured out this: > > > highest = MyModel.objects.all()[0] > > > Is there another, more elegant way like: highest = > > MyModel.object.filter(max(number)), so that I dont have to add the > > ordering-attribute in the medta-class? > > Sure, you can always specify ordering using order_by(). Ordering > defines default ordering, where no ordering is specified. > > -- > We read Knuth so you don't have to. - Tim Peters > > Jarek Zgoda, R&D, Redefine > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
getting max(field) with db-api
Hello, I want to perform a lookup an getting the object with the highest integer value. The Model looks something like this: MyModel: name = number = models.PositiveIntegerField() class Meta: ordering = [-number] So I figured out this: highest = MyModel.objects.all()[0] Is there another, more elegant way like: highest = MyModel.object.filter(max(number)), so that I dont have to add the ordering-attribute in the medta-class? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
FileUploadHandler Temp-file delete problem
When I use the TemporaryFileUploadHandler I get the following exception: [Errno 13] Permission denied The problem is that the temporary-upload files dkhskjds.upload cannot be deleted When taking a look on the stack-trace I discovered this: 82. try: 83. os.remove(old_file_name) ... 84. except OSError, e: 85. # Certain operating systems (Cygwin and Windows) 86. # fail when deleting opened files, ignore it 87. if getattr(e, 'winerror', 0) != 32: 88.# FIXME: should we also ignore errno 13? 89.raise So does anyone know how to handle this ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
FileUploadHandler Temp-file delete problem
When I use the TemporaryFileUploadHandler I get the following exception: [Errno 13] Permission denied The problem is that the temporary-upload files dkhskjds.upload cannot be deleted When taking a look on the stack-trace I discovered this: 82. try: 83. os.remove(old_file_name) ... 84. except OSError, e: 85. # Certain operating systems (Cygwin and Windows) 86. # fail when deleting opened files, ignore it 87. if getattr(e, 'winerror', 0) != 32: 88.# FIXME: should we also ignore errno 13? 89.raise So does anyone know how to handle this ? --~--~-~--~~~---~--~~ 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: Problem with global variables in modules
solved :-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with global variables in modules
Hello, this is more a python-specific problem then a django one. I have 2 modules #a.py: global filebuffer filebuffer = [] #b.py print filebuffer --> filebuffer not defined ___ Do I have to import a.py? but I want to work on the same instance of filebuffer from both modules? Any ideas? Thanks -Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Exceptions in FileUploadHandlers
I wrote a custom FileUploadHandler to process uploaded data on the fly. My problem is that there are no exceptions raised. No matter if I am referencing a variable before I assign it, or if I do something like raise Exception(). The server seems to get stuck. The Exception does not bubble to the surface. For me it looks like a bug?! Any experiences or ideas? otherwise I will open a ticket. Thanks,Toni --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Hi Karen, for me it seems very very strange. The code I used is so simple and theoretical does not contain any bugs. I deleted every file that I uploaded in a former trial, so I dont have any file with the - for test purposes static - filename test.txt in my media-directory. What happens is what was described in the ticket: django thinks the file already exists and therfore appends an underscore. Anyway it must be something that is specific to my computer and configuration. I use the newest revision, I dont have any file with that name in the target-directory, I even took a look on the rights of the target folderso theoretical it might work - but practical it doesnt. I will try to test this tomorrow on another computer - I know this is not a logical approach to fix this, but the problem itself does not seem logical to me. Anyway, I thank you very much for your help. If you ll have any ideas - please let me know. If I found what my problem was I will post it here. Thanks Toni --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Thanks for your help. Datafile is a model and just contains a CharField, a FileField a ForeignKey and some Booleanfields. --- class DataFile(models.Model): name = models.CharField(max_length=255, null = True) file = models.FileField(upload_to="data", blank = True, null=True) experiment = models.ForeignKey(Experiment) ready = models.BooleanField(null = True)# indicates if file is already labeled uploading = models.BooleanField(null = True)# indicates if file is still uploading -- In my view I just try to use the temporaryFileUploadHandler(). Former I used my own Subclass, but to be sure I just used the django-native one. This is how I perform the upload: - def upload(request, id): form = FileForm() experiment = get_object_or_404(Experiment, pk=id) request.upload_handlers = [TemporaryFileUploadHandler()] if request.method == 'POST' and request.FILES: form = FileForm(request.POST, request.FILES) if form.is_valid(): datafile = DataFile(experiment = experiment, name = "test", file = form.cleaned_data['file']) datafile.file.save('test.txt', request.FILES['file'], save=False) datafile.save() --- I am using revision 1.0 beta 2 -8626 (XP SP2). The code is realy simple. The only thing I am doing is to use the TemporaryUploadHandler. And as result I have the >200 files in my media-directory. When I wrote the first post, I had the old djangoversion and with that I got the windows-error(because the filename was longer than 215). With the new version I dont get this error, but it seems as if the server gets stuck in an endlessloop. It just idles there. Further I tried to change FILE_UPLOAD_TEMP_DIR = PROJECT_HTDOCS + '/ media/temp/' Same result, more than 200 copies in my directory. Thanks for your help, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Uploadhandler exceptions not raised
Hello, I wrote a custum Uploadhandler for processing the chunks of an uploaded file during upload. class MyFileUploadHandler(MemoryFileUploadHandler): ... def receive_data_chunk(...): convert_data(raw_data) ___ def convert_data(...): raise Exception() The exceptions I raise here never "bubble to the surface". The server just seems to stand still. Why that`? any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
TemporaryFileUploadHandler missbehaviour
Hello, I already posted a message describing this problem. For me solving this problem is very important because I cant proceed for hours. http://code.djangoproject.com/ticket/8333 in a few words: when I want to upload a file with temporaryFileUploadHandler than in fact I have 215 copies of the file in my media-directory. It seems that there is an endless loop that says FileAlreadyExists and so appends a _. In the end the file looks like this: filename..txt I dont know where the problem is. any ideas? 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: FileUploadHandler does strange things
Hm, now I have the newest Revision 8618, but still the missbehaviour that the file is copied in an endless loop. any ideas? --~--~-~--~~~---~--~~ 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: FileUploadHandler does strange things
Hi Karen, yes I also stumbled over this ticket 3 minutes ago. My Revision is 8423 - so I better check out a new one :-) Hope this will fix it, but I guess. Thank you! Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
FileUploadHandler does strange things
Hello, I have a class that looks like this: -- class MyUploadHandler(TemporaryFileUploadHandler): pass -- my view looks like this: --- request.upload_handlers = [uploadhandlers.MyUploadHandler()] datafile = DataFile(...) datafile.file = form.cleaned_data['file'] datafile.file.save('aa.txt', request.FILES['file'], save=False) datafile.save() When I am uploading a file and taking a look at the directory where the files should be stored, I produced 212 files aa.txt to aa_...___.txt. Furthermore I get an IOError for "no such file or directory", which is probably because filenames longer than 212++ are not allowed. When I edit my UploadHandlerClass and extending from MemoryFileUploadHandler: -- class MyUploadHandler(MemoryFileUploadHandler): pass -- everything works fine. So the problem must lie in the native implementation of TemporaryFileUploadHandler. I have seldom seen such strange things. Any ideas? I already spent - no wastet - hours for that. Thanks, Toni --~--~-~--~~~---~--~~ 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: problem with permalink
Yes, I tried this but the problem still exists. it s the same when I do like this: @permalink def get_url(self): return ('experiment_view', (), {'exp_id': self.id}) and the same when I do it like in the example [1]: def get_url(self): return ('experiment_view', (), {'exp_id': self.id}) get_url = permalink(get_url) For me it seems as if django could not figure out the corresponding url. any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
problem with permalink
Hello, I have a very strange problem with the permalink-decorator: model: def get_url(self): return permalink('experiment_view', (), {'exp_id': self.id}) urls.py: ... url(r'^(?P\d+)$', 'edit_experiment', name='experiment_view'), in my template {{exp.get_url}} returns an empty string. But the function get_url() is invoked. The problem is the permalink decorator. It seems as if he can not resolve the url. I dont have any idea what I am doing wrong. Thanks for your help. Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic models keyError
Hello, I am trying to generate models at runtime. For this purpose I am using the method create_model() provided at http://code.djangoproject.com/wiki/DynamicModels create_model(name, fields, module='app.models' ) When I am doing like this i get a keyError '__module__' then I tried to pass the whole path: create_model(name, fields, module='project.src.app.models' ) Still got an keyError, but this time it looked like this: keyError 'project.src.app.models' Any ideas what I am doing wrong. Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Validation Problem with ModelChoiceField
Hello, I have a serious validation problem with a form using a ModelSchoiceField. Forms: class MyModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): return "%s" % obj.name class PictureForm(forms.Form): image = forms.ImageField(label='Picture') gallery= MyModelChoiceField(models.Gallery.objects.none(), empty_label=None) __ View: picture_form = forms.PictureForm() picture_form.fields['gallery'].queryset = Gallery.objects.filter(...) It displays all fine, my ModelchoiceField has all Gallery-Entries I pass. But when it comes to validation an ValidationError is raised. I cannot understand this at all. Everthing is properly passed to the server. request.POST['gallery'] is the right Gallery-id, everthing seems fine but it does not work. Please help me, these ModelChoiceField drive me crazy! Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ModelChoiceField setting value manually
Hello, I try to set data for a ModelChoiceField() manually. This means the data is not in my db, so it s not in a Queryset. my form: class PictureForm(forms.Form): image = forms.ImageField(label='Picture') gallery= MyModelChoiceField(models.Gallery.objects.none(), empty_label=None) - If there are galleries I populate the modelChoiceField like this: [1] picture_form.fields['gallery'].queryset = Gallery.objects.filter(...) --- if ther are no Galleries I want to populate the modelChoiceField with an entry "Default" Default this Default-select-option I want to fill in manually, because it does not exist in the DB. because it works the [1]-way I thought about building a queryset manually, but I could not figure out how to do this. Can anyone please give me a short example how to build and fill a queryset manually, or show me a more elegeant way how to populate the modelchoicefield with data not comming from the database. Thanks,Toni --~--~-~--~~~---~--~~ 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: How to use dynamic choice in a ChoiceField
Thanks Nathaniel, but where and how do I pass the Queryset? From my view? I am sorry but I dont understand completly class MyModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): return "My Object #%i" % obj.id class PictureForm(forms.Form): image = forms.ImageField(label='Picture') gallery= MyModelChoiceField(..) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to use dynamic choice in a ChoiceField
Hello, I am trying to do something like this class PictureForm(forms.Form): image = forms.ImageField(label='Picture') gallery= forms.ChoiceField(Gallery.objects.all()) this just works fine, but I only want to pass several Galleries to the ChoiceField... something like: ... gallery = forms.ChoiceField(Gallery.objects.filter( ...)) so how can I do this? Thanks,Toni --~--~-~--~~~---~--~~ 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: Getting the name of a class
Hi, thanks for your answer but I already tried this and it returns something like this: But I only need the Name of the class. And it seems that __class__ returns the parent class of my model... is there any other way? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting the name of a class
I have an object that represents a modelClass. when I do print(obj) then I obviously get something like this: Is there a way to retrieve only the name of the model? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting the name of a class
I have an object that represents a modelClass. when I do print(obj) then I obviously get something like this: Is there a way to retrieve only the name of the model? Thanks, Toni --~--~-~--~~~---~--~~ 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: How to pass params to a method that is invoked when a signal was send
So, I found the solution for the problem by myslef. dispatcher.connect(makeSeoble, signal=signals.post_save, sender=model) ... my makeSeoble method needs to look like this: def makeSeoble(sender) :-) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to pass params to a method that is invoked when a signal was send
Hello, I am trying soething like this: dispatcher.connect(makeSeoble(model), signal=signals.post_save, sender=model) but I get an exception: cannot create weak reference to 'NoneType' object so it seems that you cannot pass a param to your "callback function" the classical way. when I am doing like this everything seems fine, but I cant pass the model to makeSeoble. dispatcher.connect(makeSeoble, signal=signals.post_save, sender=model) Does anyone has an ideas how I can get the model in my makeSeoble method? --~--~-~--~~~---~--~~ 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: Extending the method that is called the first time a model is deployed.
Hi, It seems as if these signals have to be used in management.py, but what I need is something I can use directly in my model code. Something like overloading a method. The fact that this should be happen in the model-class is very important. E.g I dont want every model to be registerd in my "meta-model" Apps only some of my models. One Idea was to implement this kind of registration everytime a model is instantiated and checking if there is already an entry. But this a hack because I really need this only one time (the first time the model is deployed.) any ideas? Thanks, Toni --~--~-~--~~~---~--~~ 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: Thanks!!!!!!!!!!!!!!!!!
I saw this an I had no other chance than to join the THANKS-Post. Django is a revolution for all the webdeveloppers that had a undesirable life under the lordship of all these php-frameworks. I LOVE DJANGO, and python too. Poetry pure! THANK YOU DJANGO-PEOPLE --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extending the method that is called the first time a model is deployed.
I want to register a specific model(not an object of the model, the model itself) in another model. This should be done the first time the model is deployed with syncdb. So what I need is the function that is called the first time a model is deployed, so that I can extend this function and register the model in my App-Model: pseudoCode: class Category(models.Model) . def __deploy__(): super(self, Category).__deploy__() app = App(object_name = self.__class__.name) app.save() Has anyone an idea which method is used for deploying a model? Thank you, Toni --~--~-~--~~~---~--~~ 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: Custom validationrules for newforms?
:-), I swear I went trough the documentation, but I didnt find this point. Thank you! Rishabh Manocha schrieb: > http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validationis > probably what you're looking for. > > Best, > > Rishabh > > On Wed, Jun 11, 2008 at 3:20 PM, mwebs <[EMAIL PROTECTED]> wrote: > > > > > I want to add a custom validation rule for a newforms form. > > I could not figure out how to do this. Can someone give me an advice > > how to do this. thanks, toni > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom validationrules for newforms?
I want to add a custom validation rule for a newforms form. I could not figure out how to do this. Can someone give me an advice how to do this. thanks, toni --~--~-~--~~~---~--~~ 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-tagging: Tagfield + counts-functionality problem
Hello, I have a model that looks like this class Picture(models.Model): tags = Tagfield(maxlength=255) In my view I want to display how many pictures have been tagged with a specific tag. In the docs of django-tagging I read about an additional attribute calles "counts = True". But if I add this to the TagField I get an "unexpected keyword" exception. Any ideas how I can get this to work? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with CommaSeperatedIntegerField
Hello, i get an "Error binding parameter 4 - probably unsupported type."- Interface error my model looks like this name = models.CharField(max_length=100, unique = True) active = models.BooleanField() image= models.ImageField(upload_to = 'scroller/', null=True) image_thumbnail= models.ImageField(upload_to = 'scroller/', null=True) startpos = models.CommaSeparatedIntegerField(max_length=100) masksize = models.CommaSeparatedIntegerField(max_length=100) and I asign the values like this: m = Model.objects.get(name = name) m.startpos = (1, 2) m.masksize = (2,2) m.save() I guess that it s the commaSeperatedIntegerField that makes trubble. Any ideas? Thanks, toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to deserialize / serialize Json
Hello, I try to deserialize Json. -- data = request.POST['configuration'] print data for obj in serializers.deserialize("json", data): print obj -- print data ===> {"elements":[],"startpos":{"left":0,"top":0},"masksize":{"width": 920,"height":200},"backgroundimage":"/htdocs/gfx/aa.jpg"} But there is an error at for. Any ideas? --~--~-~--~~~---~--~~ 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: SQL != // not equal in DJANGO
I found the solution: bla.objects.filter(..).exclude(...) On 28 Mai, 10:19, mwebs <[EMAIL PROTECTED]> wrote: > I want to do something like that, but with the Django DB api: > > SELECT * FROM foo WHERe name!='Default' > > How can I do this without falling back to raw sql. > > any ideas? > > Thanks Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
SQL != // not equal in DJANGO
I want to do something like that, but with the Django DB api: SELECT * FROM foo WHERe name!='Default' How can I do this without falling back to raw sql. any ideas? Thanks Toni --~--~-~--~~~---~--~~ 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: django-tagging TagField unsupported type
I could figure out why this error was thrown. You have to remove tagging.register(object) after that the modelField TagField works perfectly. --~--~-~--~~~---~--~~ 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-tagging TagField unsupported type
Hello, I am using django-tagging and just added a tagging.fields.TagField to a Model. When running syncdb, everthinks works fine, but when saving a model-instance I get this error Error binding parameter 6 - probably unsupported type. Any idea? Thanks, Toni --~--~-~--~~~---~--~~ 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: django-tagging problem
Yes, I just forgot to import tagging.fields. Thanks for your help Toni On 28 Mai, 08:27, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > On Wed, May 28, 2008 at 1:21 AM, mwebs <[EMAIL PROTECTED]> wrote: > > > Hi Alex, > > > I was trying to use this, but I got an no-attribute-tag-field-error... > > I also tried tagging.TagField() and models.TagField() > > > Any idea? > > Try this, Toni. > > At the top of my models file, I have this import: > > from tagging.fields import TagField > > where "tagging" is the directory where I made a SVN checkout of the > django-tagging app. Make sure that's in your python-path somewhere. > This may be where your problem lies. The code for the tagging app has > to live somewhere so that your import calls can find it. > > In my model definition, I use TagField like: > > tags = TagField(max_length=255) > > When I retrieve that model, I can then get 'tags' just like I would > any attribute of the model. It will simply be a string. > > If you want to turn them into links (like to a page to show all models > with that tag), the django-tagging app has methods for that as well. > > /alex > > > On 28 Mai, 08:05, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > >> On Wed, May 28, 2008 at 1:00 AM, mwebs <[EMAIL PROTECTED]> wrote: > > >> > My problem is that a.tags returns a list with tag objects.But what I > >> > need is a String of concatenated String like > > >> > 'cool, funky, fresh, exiting' > > >> > Has anybody an idea how to do this without iterating over the list of > >> > tagobjects and concatenating them by hand? > > >> Toni, > >> Have you looked at using the TagField in the model which you are > >> tagging. This makes it really easy to get these values as an attribute > >> of the model which you are tagging. > > >> /alex --~--~-~--~~~---~--~~ 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: django-tagging problem
Hi Alex, I was trying to use this, but I got an no-attribute-tag-field-error... I also tried tagging.TagField() and models.TagField() Any idea? On 28 Mai, 08:05, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > On Wed, May 28, 2008 at 1:00 AM, mwebs <[EMAIL PROTECTED]> wrote: > > > My problem is that a.tags returns a list with tag objects.But what I > > need is a String of concatenated String like > > > 'cool, funky, fresh, exiting' > > > Has anybody an idea how to do this without iterating over the list of > > tagobjects and concatenating them by hand? > > Toni, > Have you looked at using the TagField in the model which you are > tagging. This makes it really easy to get these values as an attribute > of the model which you are tagging. > > /alex --~--~-~--~~~---~--~~ 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-tagging problem
Hello, I am using the django-tagging application which allows to tag any instance of any model within your project. What I want to to is prepopoulate a form with data using : form = forms.BlaForm(initial = {'description' = a.description, 'tags' = a.tags} ) My problem is that a.tags returns a list with tag objects.But what I need is a String of concatenated String like 'cool, funky, fresh, exiting' Has anybody an idea how to do this without iterating over the list of tagobjects and concatenating them by hand? Thanks, Toni --~--~-~--~~~---~--~~ 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: Json / Ajax problem
I am sorry :-) could answer this by googling after "django Querydict" __getitem__(key) is the solution. mwebs schrieb: > Hello, > > I am performing an ajax-post-request. > > When I print request.POST I get this: [u'wew'], u'tags': [u'weew']}> > > How can I access the values? > > > Thanks for your help. > Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Json / Ajax problem
Hello, I am performing an ajax-post-request. When I print request.POST I get this: How can I access the values? Thanks for your help. Toni --~--~-~--~~~---~--~~ 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: Problem with Querydict
Sorry, but this does not work. Maybe I am doing some mistakes. Could you please post me a snippet? On 20 Mai, 12:18, Tomás Garzón Hervás <[EMAIL PROTECTED]> wrote: > Hi, you must use get_list function on QueryDict > > mwebs escribió: > > > > > Hello, > > > I am sending JSON to the serverbackend. > > When I print reuqest.POST I get . > > Thats exactly what I was expecting. > > > But now I want to access the 'elems'. When I do request.POST['elems'] > > I get'1'. > > But I was expecting getting 2, 1. > > > Thanks for your help. > > Toni > > -- > --- > Tomás Garzón Hervás > Director de Desarrollo y Calidad IACTIVE Intelligent Solutions, S.L. > -- > Teléfono Móvil: 646760508 > > -- > > Bussines & Innovation Center (BIC) > Parque tecnológico de ciencias de la salud > Avd. de la innovación 1 > C.P. 18100 Armilla (Granada) > > --- --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with Querydict
Hello, I am sending JSON to the serverbackend. When I print reuqest.POST I get . Thats exactly what I was expecting. But now I want to access the 'elems'. When I do request.POST['elems'] I get'1'. But I was expecting getting 2, 1. Thanks for your help. Toni --~--~-~--~~~---~--~~ 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: How to get the ForeignKey?
I got the solution by myself. I just used pathon reflection: getattr(m, field.name) just returned the value of the field.name and field.name is the name of the ForeignKey. On 18 Mai, 11:31, mwebs <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following problem: > > code++ > > lookUpDict = {sequence:new_sequence, field.name : m.} > > ++ > > In this context +field+ is the ForeignKey-Field of a modelObject. With > field.name I get the name of the FK-Field, e.g 'category'. Now I need > to assign the value of the ForeignKey-Field of my modelObject . E.g. > m.category. > > The problem is that 'category' should not be hard-coded but dynamic. > So how can I get the FK? Is there something like the .pk property? > > Does anybody has an idea how to do that? > > Thank you for your help! > Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to get the ForeignKey?
Hi, I have the following problem: code++ lookUpDict = {sequence:new_sequence, field.name : m.} ++ In this context +field+ is the ForeignKey-Field of a modelObject. With field.name I get the name of the FK-Field, e.g 'category'. Now I need to assign the value of the ForeignKey-Field of my modelObject . E.g. m.category. The problem is that 'category' should not be hard-coded but dynamic. So how can I get the FK? Is there something like the .pk property? Does anybody has an idea how to do that? Thank you for your help! Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting FK-Value without knowing the name of the field
Hello, I need something like this: modelObject.fk// returns the FK-value of the modelObject --~--~-~--~~~---~--~~ 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: Dynamic lookup
Thank you Scott and Ronny! This was a great help. On 17 Mai, 13:20, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote: > On Sat, May 17, 2008 at 6:11 PM, mwebs <[EMAIL PROTECTED]> wrote: > > I am using something like this: > > > model.objects.filter(field = variable) > > > Is it possible to pass the field that is used for the lookup > > dynamically, so that field is also a variable ? > > It's python kwargs (keyword arguments). You can do this: > > dictionary = {field1: val1, field2: val2} > model.objects.filter(**dictionary) > > Ronny --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic lookup
Hello, I am using something like this: model.objects.filter(field = variable) Is it possible to pass the field that is used for the lookup dynamically, so that field is also a variable ? Thanks, Toni --~--~-~--~~~---~--~~ 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: ForeignKey information at runtime
I found the soultion: news._meta.fields[x].get_internal_type() this returns 'ForeignKey' if the field is a FK. On 17 Mai, 12:06, mwebs <[EMAIL PROTECTED]> wrote: > Thank you, > > thats exactly what I was looking for. > But how can I test if a field is a ForeignKey? > > On 17 Mai, 11:01, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > > > On Sat, 2008-05-17 at 00:59 -0700, mwebs wrote: > > > Hi, > > > > is there any possibility to get the field from a model instance that > > > speciefies a foreignkey-relationship. > > > > something like this: > > > > news.__foreignKey__ # returns 'category' > > > Just inspect news._meta.fields, you'll find what you need there. --~--~-~--~~~---~--~~ 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: ForeignKey information at runtime
Thank you, thats exactly what I was looking for. But how can I test if a field is a ForeignKey? On 17 Mai, 11:01, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > On Sat, 2008-05-17 at 00:59 -0700, mwebs wrote: > > Hi, > > > is there any possibility to get the field from a model instance that > > speciefies a foreignkey-relationship. > > > something like this: > > > news.__foreignKey__ # returns 'category' > > Just inspect news._meta.fields, you'll find what you need there. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ForeignKey information at runtime
Hi, is there any possibility to get the field from a model instance that speciefies a foreignkey-relationship. something like this: news.__foreignKey__ # returns 'category' 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: Get table name at runtime
Perfect! that is what I was searching for!!! Thanks, Toni On 17 Mai, 09:50, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > Hi, > > On Sat, 2008-05-17 at 00:44 -0700, mwebs wrote: > > Hi, > > > is there any possibility to get the db table name of a model instance > > at runtime > > (news.get_table_name())? > > Yes: > News._meta.db_table and news_object._meta.db_table both work. > > I think that _meta is an implementation detail however, therefore I > don't know if you can rely on the _meta attribute. I don't see a reason > why it should go away or be renamed however, so you are probably safe > using it. > > --http://spinlock.ch/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Get table name at runtime
Hi, is there any possibility to get the db table name of a model instance at runtime (news.get_table_name())? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with : Updating multiple objects at once
Hello, I want to do something like this: UPDATE news SET sequence = sequence-1 WHERE sequence > 5 With the database-api I tried the following: News.objects.filter(sequence__gt = msequence).update(sequence = sequence-1) But thats not possible, beacause the assignment parameter sequence-1 must be a variable and not a reference to a column-value. Is there any possibility to solve this problem without iterating over all results with News.objects.filter(sequence__gt = msequence) and setting the new sequence manually in each iteration? Thanks, Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom model field for sequence-functionality
Hello, what I need is a modelField that provides sequence-functionality for a model. This field should have the following features: - auto_increment when a new instance of the Model is created - a method move_up() // Increments the sequence of the object - a method move_down() // Decreases the sequence of the object - a method sync_order() // Syncronizes all sequences; This sould be called when a certain model-instance was deleted. The method finds the "hole" and decreses all other items greater than the one that was deleted. My plan was to extend PositiveIntegerField and adding the desired functionality. But I could not figure out how to add auto_increment, without falling back to raw sql. ...and how to add the 3 methods I mentioned above Here a short example how a Model containing the SequenceField should be used: n = News.objects.get(pk = id) n.moveUp() || n.moveDown() I am relativley new to Django, and need some help of how to implement this custom model field. Thanks, Toni --~--~-~--~~~---~--~~ 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: Problem with Deserializing JSON
Hi, its just the same error when using django.utils.simplejson. any idea, whats going wrong? On 13 Mai, 23:30, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On May 13, 5:11 pm, mwebs <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > I have some problems deserializing a json.object. I am quite new in > > using json, an I think the json is not formatted correctly. > > > When I print: > > > request.POST[elems] > > > I get a String like this: "1,2,3" > > > But when I try to to do > > > for elem in serializers.deserialize("json", data ): > > > I just get a valueError: Extra data: line 1 column 1 - line 1 column 5 > > (char 1 - 5) > > django.core.serializers.* are meant for serializing Django model > objects. > > If you want to work with primitive objects, just use > django.utils.simplejson directly. Something like: > > from django.utils import simplejson > for elem in simplejson.loads("[1, 2, 3]") --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with Deserializing JSON
Hello, I have some problems deserializing a json.object. I am quite new in using json, an I think the json is not formatted correctly. When I print: request.POST[elems] I get a String like this: "1,2,3" But when I try to to do for elem in serializers.deserialize("json", data ): I just get a valueError: Extra data: line 1 column 1 - line 1 column 5 (char 1 - 5) Thank you. Toni --~--~-~--~~~---~--~~ 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: Drop all tables
Yes, I am using sqlite, otherwise I would probably use pgadmin, or another db-acces-tool. Deleting the file an run syncdb works perfectly. Thanks for your answers. On 12 Mai, 16:20, "Chris Czub" <[EMAIL PROTECTED]> wrote: > If you are using SQLite you could just delete the database file. If not, I'm > confused at why you'd have access to the shell but not access to the > database - do you not have access to the database you are working on or > something? If so, I would ask whoever has access to it to drop the tables > for you. I don't think there'd be a shell command that would allow you to > drop database tables without having database access since that would be a > security flaw. > > If you reply with which DBMS you're using, we can give you specific > instructions for how to drop tables. > > On Mon, May 12, 2008 at 3:47 AM, mwebs <[EMAIL PROTECTED]> wrote: > > > Hi, > > > is there anyway to drop all tables without falling back to raw sql. I > > mean with an shell command or something like that? > > > Thank you > > > Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Drop all tables
Hi, is there anyway to drop all tables without falling back to raw sql. I mean with an shell command or something like that? Thank you Toni --~--~-~--~~~---~--~~ 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: Setting request-parameters per default
Thanks Alex, thats a good idea. But I want to have a more generic solution for this problem. There must be an other way than to write custom template tags. I think the passing-default-request-parameters approach is the solution, but I dont know how and where to realize it elegant. Toni On 11 Mai, 09:15, Alex Morega <[EMAIL PROTECTED]> wrote: > On May 11, 2008, at 09:58 , mwebs wrote: > > > > > > > In my application I need to build a dynamic menu. For this purpose I > > have to pass a dict that contains the menu-entries that will be > > displayed at my index.html > > > The not elegant way to do this, is to pass the menu-entries in every > > view-function. What I want to do is to pass these menu-entries per > > default (when a certain url is requestes), so that I dont have to do > > this in every tiny view-function. > > > I have had several ideas to do this (but I did not succed yet): > > > 1) urls.py > > invoking a method that inserts the default values in the > > request. (Here I had errors when inserting the method in > > the urls.py) > > > 2) middleware: writing a middleware-class that can do these "per- > > request default-jobs" > > > Does anyone has an idea how to do this in an elegant way? > > Create a custom templatetag that renders the menu; the templatetag > should be able to figure out the menu contents for itself (if the menu > is variable, pass a parameter to the tag from the template). You could > include this tag in your base template if you have one. > > Cheers, > -- Alex --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Setting request-parameters per default
In my application I need to build a dynamic menu. For this purpose I have to pass a dict that contains the menu-entries that will be displayed at my index.html The not elegant way to do this, is to pass the menu-entries in every view-function. What I want to do is to pass these menu-entries per default (when a certain url is requestes), so that I dont have to do this in every tiny view-function. I have had several ideas to do this (but I did not succed yet): 1) urls.py invoking a method that inserts the default values in the request. (Here I had errors when inserting the method in the urls.py) 2) middleware: writing a middleware-class that can do these "per- request default-jobs" Does anyone has an idea how to do this in an elegant way? Thank you very much. Toni --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---