how to show blank spaces at the start of string in django templates
Hi I formated with python numbers like e.g.: " 3457.50" " 11450.25" but my problem is to show them correctly one below the other in a column by django templates because the blank spaces are ignored. I tried with the filter escape, however it does not work. A solution would be to loop over the characters in string like: {% for c in number_string %}{% if c == ' ' %} {% else %}{{ c }}{% endif %}{% endfor %} and so to replace blank space with but this is very cumbersome. Can somebody tell me if we here have a simple and elegant solution? Thanks in advance and best regards Ogi -- 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.
Re: DatabaseError: subquery has too many columns
Obviously the subquery has too many columns, namely two: "error_test"."id", and "error_test"."name", but you want that only "error_test"."id" is NOT in select elements of the subquery. I'm not even sure that your approch makes sense. Greetings, Ogi >Hi all, >Just came across this error. >class Test(models.Model): > name = models.CharField(max_length=20) >test = Test(name='bob') >test.save() >pks = Test.objects.none().values('pk').query >print Test.objects.exclude(pk__in=pks) >DatabaseError: subquery has too many columns >The query: >SELECT > "error_test"."id", > "error_test"."name", >FROM > "error_test" >WHERE > NOT ( >"error_test"."id" > IN ( >SELECT > "error_test"."id", > "error_test"."name", >FROM > "error_test" > ) > ) >Same thing happens when: >print Test.objects.filter(pk__in=pks) >Should this be ticketed? Should I tweak the app to ensure this doesn't >happen? -- 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.
error: 'get format is not defined' in DateTimeShortcuts.js
Hi dear django users After I updated Django to version 1.2.1 and in myproject/media/js replaced the old javascripts with the new from site-packages/django/contrib/admin/media/js and site-packages/django/contrib/admin/media/js/admin I become in DateTimeShortcuts.js the error 'get format is not defined' Can somebody tell me what I'm missing? Thanks in advance and best regards Ogi -- 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.
error: get_format is not defined
Hi django users After updating Django to version 1.2.1 and replacing the old javascript files in myproject/media/js with the new files I become a error get_format is not defined in DateTimeShortcuts.js Can somebody tell me what I'm missing? Thanks in advance and best regards Ogi -- 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.
ModelAdmin - related foreign keys
Hi I'm new in Django and want to explain my issue: For instance I have model A with foreign key to B and model B with foreign key to C. I would like to have add form of C with one B (extra = 1) and within B four A (extra = 4) With the following example in admin.py I can only achieve this partly: for object C I have only extra B object without A objects related to B object. class AInline(admin.TabularInline): model = A extra = 4 class BAdmin(admin.ModelAdmin): inlines = [AInline] class BInline(admin.TabularInline): model = B extra = 1 class CAdmin(admin.ModelAdmin): inlines = [BInline] So can somebody explain me how to do dies, that I can have complete add-form inside the object C: with extra object B together with extra (sub)objects C ? Excuse me for bad english and lot of text. Thanks in advance for any hint. Best regards Ogi -- 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.
InlineModelAdmin related items on two levels
Hi all I read the very good tutorial on http://docs.djangoproject.com/en/dev/ref/contrib/admin/ and understood that the admin interface has the ability to edit models on the same page as a parent model and these are called inlines. For two related models is this easy: class A (models.Model): name =... class B(models.Model): a = models.ForeignKey(A) title = ... in admin.py: class B(admin.TabularInline): model = B class AAdmin(admin.ModelAdmin): inlines = [ B, ] and the result ist, that in add/change of A we can also add/change its child models B My Problem is that I however by B model have also child models: class C b = models.ForeignKey(B) name = ... My Question is : Is it possible than one can add/edit models of A on the one page together with child models B and C as child models of B. Any hint or idee would be very appreciated Ogi -- 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.
Re: InlineModelAdmin related items on two levels
>>On Feb 14, 6:19 am, Ogi Vranesic wrote: >> Hi all >> >> I read the very good tutorial onhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/ >> and understood that the admin interface has the ability to edit models on the >> same page as a parent model and these are called inlines. For two related >> models is this easy: >> >> class A (models.Model): >>name =... >> >> class B(models.Model): >>a = models.ForeignKey(A) >>title = ... >> >> in admin.py: >> >> class B(admin.TabularInline): > >model = B >> >> class AAdmin(admin.ModelAdmin): >> inlines = [ >> B, >> ] >> >> and the result ist, that in add/change of A we can also add/change its child >> models B >> >> My Problem is that I however by B model have also child models: >> class C > > b = models.ForeignKey(B) >> name = ... >> >> My Question is : >> Is it possible than one can add/edit models of A on the one page together with >> child models B and C as child models of B. >> >> Any hint or idee would be very appreciated >Sounds like you want nested inlines. There is no built-in way to do >this with django. I did some work (and got a solution working), but it >required significant change to the installed django. I was planning on >trying to make it into an installable app, but didn't get far. >I do have a diff: I've just put it at http://pastie.org/823968 - this >is with a fairly old trunk though, so it may not merge back in that >well right now. >It was based on another nested-inline diff I had come across, but I >don't seem to have the link any more. >Oh, and it is not flawless, there were still some issues I didn't get >sorted out. I had some validation errors of some sort, I think, when >updating data under certain circumstances, but I never quite >completely tracked it down. > Matt. Hi Matt Thank you very much for Your reply and effort to manage this issue. It's pitty, that nested lists are not implemented in django. I'll look Your diffs on http://pastie.org/823968 and try to do something. Best regards Ogi -- 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.
override change_form.html & submit_line.html
Hi In order to adapt them I would like to override following templates: contrib/admin/templates/admin/change_form.html contrib/admin/templates/admin/submit_line.html and probably also contrib/admin/templates/admin/edit_inline/tabular.html In my project I have already a directory /emplates/admin and I can put my customizations there, but I don't know how to tell django to use them instead of standard templates mentioned above Can somebody tell me what is the best way to do this? Thanks in advance and best regards Ogi -- 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.
Re: override change_form.html & submit_line.html
>> Hi >> > >In order to adapt them I would like to override following templates: >> >> contrib/admin/templates/admin/change_form.html >> contrib/admin/templates/admin/submit_line.html >> and probably also >> contrib/admin/templates/admin/edit_inline/tabular.html >> > >In my project I have already a directory /emplates/admin >> and I can put my customizations there, but I don't know >> how to tell django to use them instead of standard templates mentioned >>above >> >> Can somebody tell me what is the best way to do this? >> >> Thanks in advance and best regards >> Ogi >http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#overriding-admin- >templates >-- >DR. Hi Daniel Thanks very much for the answer. Ogi -- 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.
Re: Extremely Frustrated
Could You also send us the definition of Book class? Ogi On Donnerstag 21 April 2011 10:00:17 pm you wrote: > Hello, > > I have been working through the Django Book, and I keep getting syntax > errors in the examples in Chapter 6. > > The following example works: > > class BookAdmin(admin.ModelAdmin): > list_display = ('title', 'publisher', 'publication_date') > list_filter = ('publication_date',) > date_hierarchy = 'publication_date' > ordering = ('-publication_date',) > fields = ('title', 'authors', 'publisher', 'publication_date') > > The next one, however, does not - it throws a syntax error: > > class BookAdmin(admin.ModelAdmin): > list_display = ('title', 'publisher', 'publication_date') > list_filter = ('publication_date',) > date_hierarchy = 'publication_date' > ordering = ('-publication_date',) > fields = ('title', 'authors', 'publisher') > > Nor can I add fields back in to this example or I get a syntax error: > > class BookAdmin(admin.ModelAdmin): > list_display = ('title', 'publisher', 'publication_date') > list_filter = ('publication_date',) > date_hierarchy = 'publication_date' > ordering = ('-publication_date',) > filter_horizontal = ('authors',) > (would like to still define fields, but throws a syntax error) > > Same with this one: > > class BookAdmin(admin.ModelAdmin): > list_display = ('title', 'publisher', 'publication_date') > list_filter = ('publication_date',) > date_hierarchy = 'publication_date' > ordering = ('-publication_date',) > filter_horizontal = ('authors',) > raw_id_fields = ('publisher',) > (would like to still define fields, but throws a syntax error) > > > Could someone please show me how to include "fields = ('title', > 'authors', 'publisher')" without getting an error? > > Thanks, > Gandeida > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ajax select box
Hallo You can use Dajax(ice) to solve your issue. First Dajax and Dajaxice must be installed. In your select box for countries add event 'onchange' i.e.: onchange="Dajaxice.ajax.getCitiesByCountry('Dajax.process', {'name':this.name, 'value':this.value})"> According to this example you must have the file ajax.py and the function getCitiesByCountry must be registered in settings.py like: DAJAXICE_FUNCTIONS = ( 'ajax.getCitiesByCountry', ) Afterwards define the function getCitiesByCountry in ajax module where you can generate options for cities using python and replace them automatically in html. If something is not clear google for Dajax, Dajaxice, dajax.json() Greetings Ogi On Sonntag 08 Mai 2011 06:46:54 pm you wrote: > but i dont know about jquery or ajax, can i get any example from any > site , can u provide any link which has such code written > > On May 7, 12:10 pm, Shawn Milochik wrote: > > You'll need to write JavaScript. > > > > Specifically: > > > > Write a function that uses AJAX to pass the state to a Django view > > and receive the city list, then populate the city drop-down. > > > > Bind that function to the change event of your state drop-down box. > > > > This isn't a Django question, though. If you have trouble doing that try > > a JavaScript mailing list. > > > > I recommend using jQuery's .ajax() function for this. > > > > Shawn > -- 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.
ValueError: Need 2 values to unpack in for loop; got 3 (actually num_loopvars = 2 and len_item = 3)
Hi I have used some templates in older django versions. But now in django 1.11 using the same templates, the error: ValueError: Need 2 values to unpack in for loop; got 3. will be raised on line 207 in module django.template.defaulttags by the method render of class ForNode Actually is by me looking at code *num_loopvars = 2* and *len_item = 3*. After I've outcommented this part of code, some of this template as a form is displayed and one can work on it. So could somebody tell me what is purpose of this two variables and comparing of them? Thanks very much in advance and best regards Ogi -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2954a3e8-4590-64ce-1264-39c3e05b1dde%40redcor.ch. For more options, visit https://groups.google.com/d/optout.
ValueError: Need 2 values to unpack in for loop; got 3 (actually num_loopvars = 2 and len_item = 3)
Michal, Thanks very much for your reply. I guessed, that is something like in your example. And I find it in template. So the conclusion is that there is no more allowed in django template engine to use *for* loop with less elements to unpack, and I think that is also consistent and more pythonic. Best regards Ogi On 17.07.2017 16:08, Michal Petrucha wrote: On Mon, Jul 17, 2017 at 03:46:30PM +0200, Ogi Vranesic wrote: Hi I have used some templates in older django versions. But now in django 1.11 using the same templates, the error: ValueError: Need 2 values to unpack in for loop; got 3. will be raised on line 207 in module django.template.defaulttags by the method render of class ForNode Actually is by me looking at code *num_loopvars = 2* and *len_item = 3*. After I've outcommented this part of code, some of this template as a form is displayed and one can work on it. So could somebody tell me what is purpose of this two variables and comparing of them? Thanks very much in advance and best regards Ogi Sounds like you are trying to loop over a list in your template, something like this:: {% for a, b in mylist %} ... {% endfor %} The problem is that mylist contains triples, not pairs. It would help a lot if you could show the actual template code, as well as the context that you pass to the template. Cheers, Michal -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3478a2a2-166a-df65-9ca8-35873b2aa008%40redcor.ch. For more options, visit https://groups.google.com/d/optout.