Extremely Frustrated
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: Extremely Frustrated
Hello, I am running version 1.3. After copying and pasting about 20 more times, but getting the error sporadically, I have found that the issue was the tab characters that were being automatically generated to keep my indentation level. I've changed it to use spaces instead. Thank you for offering to help, though! I just figured it out by accident :-) Regards, 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: Extremely Frustrated
Hi Ogi, It turned out that I had some tab characters in my code that I inadvertently added when I copied and pasted. I've changed my editor settings to use spaces instead of tabs, and all is working now. Thank you for offering to help! Regards, Gandeida On Apr 22, 6:04 am, Ogi Vranesic wrote: > 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- Hide quoted text - > > - Show quoted text - -- 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.