Hi everybody, being new in Django, I'd like to ask you for some tips about what should be in views.py and what shouldn't be.
I'm writing a blog app with custom views.py. I know that it would be a lot easier (and wiser) to use generic views for what I'm trying to accomplish, but I'd like to learn new things along the way, so I decided to write my own views.py. Anyway, that's what bugs me: def get_all_tags(): tags = [] tags_db = Tag.objects.all() for tag in tags_db: tags.append({ 'tag': tag.tag, 'url': tag.get_absolute_url() }) return tags def get_entries_list(entries_list): entries = [] for entry in entries_list: entries.append({ 'body': mark_safe(entry.body), 'pub_date': entry.pub_date, 'title': entry.title, 'url': entry.get_absolute_url(), 'tags': entry.get_tags(), }) return entries def show_entries_by_day(request, year, month, day): now = datetime.datetime.now() # Check if day is in the future if year + month + day > ''.join([str(now.year), str(now.month), str(now.day)]): raise Http404 entries = Entry.objects.filter(pub_date__lte=now, pub_date__year=year, pub_date__month=month, pub_date__day=day, status=1) return render_to_response('blog_entry.html', {'entries': get_entries_list(entries), 'tags': get_all_tags()}) I have a function similar to show_entries_by_year() for month, day, tag and slug. Now, for get_all_tags(), I'm planning to write a template tag that would replace this function, but I still don't know what to do with get_entries_list(). I only made this function in order to not repeat myself. Is there a way to get rid of get_entries_list() and somehow make my views.py cleaner? I tried to pass entries directly to the template but it didn't quite work (maybe I'm missing something). I searched the web for some examples, but it's hard to find apps that don't use generic views (at least I didn't find them), so I decided to ask here. Thanks Matic Žgur --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---