Re: adding user instance to the comments constructor for a dynamic comment form
On Sun, 29 Aug 2010 16:08:45 -0700 (PDT) Cody Djangowrote: > I'd like to have the comment form contain a captcha if the user is > logged in. Do you mean "have the comment form contain a captcha if the user *is not* logged in? -E -- 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.
saving an object twice
Hi All, I have a model CampaignYear that is registered with django-reversion so that when a CampaignYear instance is saved a django-reversion Version object is also saved. This worked great until I wanted to do the following: add a field to CampaignYear, last_editor(), that queries the latest Version object related to my CampaignYear instance and returns a string combining the user, date, and comment associated with that version. My code for this is below: def last_editor(self): # Get latest version from reversion version = Version.objects.get_for_date(self, datetime.datetime.now()) # Get data from version user = version.revision.user date_strf = version.revision.date_created.strftime("%b %d, %I:%M%p") comment = version.revision.comment last_editor = (u'%s : %s - %s' % (user, date_strf, comment)) return last_editor This works, but is very database intensive and slow. So I want to create a CharField in CampaignYear called last_editor_str that contains the value returned by last_editor(), so that this computation is only done when I save the object, rather than every time I want to view it. My problem is here: the Version object associated with each CampaignYear isn't created until after I save CampaignYear. So I need to save CampaignYear once and then save it again with last_editor_str populated from my last_editor() function. So my question is how should I go about doing this double save? One thing I tried was using super(CampaignYear, self).save(*args, **kwargs) twice in CampaignYear.save(). Once before last_editor_str is populated and then again after. This didn't work. I don't know if you can use super().save() twice? I also tried using signals: def camp_year_post_save(sender, **kwargs): if (sender.last_editor_str == ''): try: sender.last_editor_str = sender.get_last_editor() sender.save() except Version.DoesNotExist: pass post_save.connect(camp_year_post_save, sender=CampaignYear) However, this threw a AttributeError: type object 'CampaignYear' has no attribute 'last_editor_str' error. If I can clarify anything please let me know, Thanks, Evan -- 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.
Where is the source code for Practical Django Projects?
Hi, I am reading Practical Django Projects but am unable to find the online source code. Does anyone know where this is located? I would think that it would be at http://www.apress.com/book/view/1590599969. However, that doesn't seem to be the case. Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
embedding django-contact-form in a generic view
Hi, I have a archive index generic view that is working at /portfolio/. I also have a http://code.google.com/p/django-contact-form/ contact form at /contact/. I want to have the form currently located at /contact/ be on the same page as my generic view at /portfolio/. I am wondering what is the simplest way to achieve this. Thank You, Evan --~--~-~--~~~---~--~~ 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: solving fixture data conflicts
Russell Keith-Magee wrote: > The only real solution at present is to avoid serializing content > types whenever possible (i.e., by not dumping the contenttypes > application). If your fixture already has content types, manually > delete them from the fixture before loading. How can I go about manually deleting the content types? Is there something I should look for in my file exported with dumpdata? Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
solving fixture data conflicts
Hi, I am trying to loaddata from a file, bmdata.xml and getting an error: Problem installing fixture 'bmdata.xml': duplicate key violates unique constraint "django_content_type_app_label_key" I understand that there is a conflict in the fixture data. However, I don't know how to solve it. I only ran syncdb before loaddata, and did not create any content. Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
fastcgi problem: runfcgi not creating socket file
Hi, I am having some trouble trying to setup Django SVN on a shared web host with lighttpd and flup (Joyent's Shared Accelerator). I have setup lighttpd and it runs seemingly fine. I am unable to get the fastcgi socket to be created with the runfcgi command. In particular, the command I am testing testing with is: /usr/local/bin/python manage.py --verbosity=2 runfcgi method=prefork socket="/users/home/carmi/django_projects/binarymanipulations/binarymanipulations.socket pidfile="/users/home/carmi/django_projects/binarymanipulations.pid I can run this command without any problems, but a socket file is not created. (The pidfile is created.) Even with --verbosity=2 I do not get any error messages. I have the following in my lighttpd error log file: 2008-02-11 05:49:04: (log.c.75) server started 2008-02-11 05:49:32: (mod_fastcgi.c.1731) connect failed: No such file or directory on unix:/users/home/carmi/django_projects/binarymanipulations/binarymanipulations.socket 2008-02-11 05:49:32: (mod_fastcgi.c.2885) backend died; we'll disable it for 5 seconds and send the request to another backend instead: reconnects: 0 load: 1 2008-02-11 05:49:34: (mod_fastcgi.c.3496) all handlers for /binarymanipulations.fcgi/ on /binarymanipulations.fcgi are down. 2008-02-11 05:49:38: (mod_fastcgi.c.2703) fcgi-server re-enabled: unix:/users/home/carmi/django_projects/binarymanipulations/binarymanipulations.socket Is there someplace else I can look for some errors or other information that will help me get this running? Or anything else I should do? Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
truncating posts with markdown
Hi, I ran across a problem today with the list view of my blog. I am using markdown to create html tags for my post. In the list view I use the template tag truncate to cut off the number of words. This leaves open the html tags that markdown created. I am wondering what ways people get around this? Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
request.path in a context processor
Hi, Here I have a context processor --> http://dpaste.com/18402/ I have {{ base_path }} in one of my templates but it isn't returning anything. I am not sure if I can use request.path the way I am using it. Any ideas? Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
type object 'HtmlFormatter' has no attribute 'encoding'
Hi, I am trying to get pygments and markdown highlighting working on my blog. When I try and save a post that has ` in it I get an attribute error. My models are (more beautifully here http://dpaste.com/17230/) ignore the _highlight_python_code part. that was from a previous attempt: from django.db import models import datetime # Create your models here. class Tag(models.Model): slug = models.SlugField( prepopulate_from=("name",), help_text='Automatically prepopulated from name', ) name = models.CharField(maxlength=30) description = models.TextField( help_text='Short summary of this tag' ) def __str__(self): return self.name def get_absolute_url(self): return "/blog/tag/%s/" % self.slug class Admin: list_display = ('name', 'slug', ) search_fields = ('name', 'description',) class Entry(models.Model): title = models.CharField(maxlength=255, core=True, unique_for_date="pub_date") pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True, help_text='Use http://daringfireball.net/projects/markdown/syntax;>Markdown-syntax') body_html = models.TextField(blank=True, null=True) use_markdown = models.BooleanField(default=True) tags = models.ManyToManyField(Tag, filter_interface=models.HORIZONTAL) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'tags', 'use_markdown', 'pub_date', 'body', 'body_html',)}), ) def __str__(self): return self.title def get_absolute_url(self): return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug) #from http://www.unessa.net/en/hoyci/2006/11/highlighting-code-using-pygments-and-beautiful-soup/ def _highlight_python_code(self): from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(self.body) python_code = soup.findAll("code") if self.use_markdown: import markdown index = 0 for code in python_code: code.replaceWith('mark %i' % index) index = index+1 markdowned = markdown.markdown(str(soup)) soup = BeautifulSoup(markdowned) markdowned_code = soup.findAll("p", "python_mark") index = 0 for code in markdowned_code: code.repalceWith(highlight(python_code[index].renderContents(), PythonLexer(), HtmlFormatter())) index = index+1 else: for code in python_code: code.replaceWith(highlight(code.string, PythonLexer(), HtmlFormatter())) return str(soup) #from dpaste.com/16735 def markup(self, value): import re from BeautifulSoup import BeautifulSoup from pygments import highlight from pygments.formatters import HtmlFormatter from pygments.lexers import guess_lexer, get_lexer_by_name from markdown import markdown value = markdown(value) tree = BeautifulSoup(value) try: for code in tree.findAll("code"): print code.contents[0].__dict__ lexer = get_lexer_by_name('python', stripall=True) formatter = HtmlFormatter new_content = highlight(code.contents[0], lexer, formatter) code.replaceWith(new_content) value = str(tree) except IndexError: pass return value def save(self): self.body_html = self.markup(self.body) super(Entry,self).save() I was trying to save a post with the following content: `print "hello world"` I am using a PostgreSQL database. Thanks, Evan --~--~-~--~~~---~--~~ 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
Pygments + Markdown
Hi, I am trying setup pygments and markdown described here: http://www.unessa.net/en/hoyci/2006/11/highlighting-code-using-pygments-and-beautiful-soup/ My Model.py is: (Also here http://dpaste.com/hold/16731/) - from django.db import models import datetime # Create your models here. class Tag(models.Model): slug = models.SlugField( prepopulate_from=("name",), help_text='Automatically prepopulated from name', ) name = models.CharField(maxlength=30) description = models.TextField( help_text='Short summary of this tag' ) def __str__(self): return self.name def get_absolute_url(self): return "/blog/tag/%s/" % self.slug class Admin: list_display = ('name', 'slug', ) search_fields = ('name', 'description',) class Entry(models.Model): title = models.CharField(maxlength=255, core=True, unique_for_date="pub_date") pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True, help_text='Use http://daringfireball.net/projects/markdown/syntax;>Markdown-syntax') body_html = models.TextField(blank=True, null=True) use_markdown = models.BooleanField(default=True) tags = models.ManyToManyField(Tag, filter_interface=models.HORIZONTAL) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'tags', 'use_markdown', 'pub_date', 'body', 'body_html',)}), ) def __str__(self): return self.title def get_absolute_url(self): return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug) #from http://www.unessa.net/en/hoyci/2006/11/highlighting-code-using-pygments-and-beautiful-soup/ def _highlight_python_code(self): from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(self.body) python_code = soup.findAll("code") if self.use_markdown: import markdown index = 0 for code in python_code: code.replaceWith('mark %i' % index) index = index+1 markdowned = markdown.markdown(str(soup)) soup = BeautifulSoup(markdowned) markdowned_code = soup.findAll("p", "python_mark") index = 0 for code in markdowned_code: code.repalceWith(highlight(python_code[index].renderContents(), PythonLexer(), HtmlFormatter())) index = index+1 else: for code in python_code: code.replaceWith(highlight(code.string, PythonLexer(), HtmlFormatter())) return str(soup) def save(self): import markdown self.body_html = self._highlight_python_code() super(Entry,self).save() - If I create an entry with use_markdown True, and body: this is a regular paragraph `print "hello world"` the body_html is: this is a regular paragraph print hello world If I create an entry with use_markdown False, and body: this is a regular paragraph print "hello world" the body_html is: this is a regular paragraph print hello world I want markdown to find my code blocks or code spans and then let them be colored by pygments. If I turn use_markdown to False, pygments works. If it is True, pygments doesn't work. Maybe there is a problem with the replaceWith() markdowned_code and it isn't getting changed in soup, which is then returned. Thanks, Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
database table doesn't exist
Hi, I was implementing tags on my blog and ran into this problem: Under the administration page I can create and view tags. I can also view a list of entries and try and create an entry. When I try and create an entry I can fill out the entry form and save it. The data is saved and appears on my blog but I get the following error: (I also get this error when trying to view the details for an entry.) ProgrammingError at /admin/blog/entry/7/ (1146, "Table 'django_.blog_entry_tags' doesn't exist") Request Method: GET Request URL:http://binarymanipulations.com:8157/admin/blog/entry/7/ Exception Type: ProgrammingError Exception Value:(1146, "Table 'django_.blog_entry_tags' doesn't exist") Exception Location: /usr/local/lib/python2.4/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 35 Python Executable: /usr/local/bin/python Python Version: 2.4.3 [snipped] My blog/models.py is below (and here http://dpaste.com/hold/16673/) : from django.db import models import datetime # Create your models here. class Tag(models.Model): slug = models.SlugField( prepopulate_from=("name",), help_text='Automatically prepopulated from name', ) name = models.CharField(maxlength=30) description = models.TextField( help_text='Short summary of this tag' ) def __str__(self): return self.name def get_absolute_url(self): return "/blog/tag/%s/" % self.slug class Admin: list_display = ('slug', 'name',) search_fields = ('name', 'description',) class Entry(models.Model): title = models.CharField(maxlength=255, core=True, unique_for_date="pub_date") pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True) tags = models.ManyToManyField(Tag, filter_interface=models.HORIZONTAL) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'tags', 'pub_date', 'body',)}), ) def __str__(self): return self.title def get_absolute_url(self): return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug) I have ran python manage.py syncdb. I really don't know what is going on but I have a slight idea it might have something to do with the Entry tags field. It seems like django wants to see a blog_entry_tags table in the database but it isn't there. Maybe a problem with the ManyToManyField? Thanks, Evan --~--~-~--~~~---~--~~ 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: refreshing won't reload page
Florian Apolloner wrote: > After editing your code, you will need to touch fcgi file Can you be more explicit. I know the location of a lighttpd.sh init file. But I am not sure if there is a fcgi file somewhere? Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
refreshing won't reload page
Hello, I am running Django with lighttpd. I will make a change in the code and try and refresh the page through firefox. The page will reload but error page shows me the old code. I can refresh it 20-30 times before it will reload the new code. It seems as if something is being cached. I don't think that it is my browser because refresh should not load from the cache. Does lighttpd or django cache things automatically? Can I turn this off during development? Evan --~--~-~--~~~---~--~~ 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: Best practices to provide Django on a shared host
Fabien Schwob wrote: > Hello, > > I'm currently hosting my Django websites on a dedicated server and it > works fine. I restart Apache when I make modifications since I'm alone > on the box. > > But I've made evangelism for Django and I've convinced some friends to > use it. So I would like to take a new server and to set up a "Django > Shared Hosting". What is the best way to do that ? > > - One Apache instance by user/website (I've seen that on > http://www.gypsyhosting.com/) ? But how to do that does someone have > some links to do that ? > > - Using lighttpd and FGCI ? > > - Using Apache and FCGI, so the user only need to *touch* the fcgi script. > > My goal is to build my shared hosting and to create a document on how > to do that. So, any help are welcome. > > Thanks. > Textdrive (Joyent) offers Django hosting. There is an install script that will setup Django for you: http://textusers.com/wiki/Installing_Django Evan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Generic Views: "Could not parse the remainder: % object.title %"
I am trying to use generic views for a hand built weblog app. I am getting a template error of "Could not parse the remainder: % object.title %" My blog/urls.py is: - from django.conf.urls.defaults import * from binarymanipulations.blog.models import Entry info_dict = { 'queryset': Entry.objects.all(), 'date_field': 'pub_date', } urlpatterns = patterns('django.views.generic.date_based', (r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(?P[-\w]+)/$', 'object_detail', dict(info_dict, slug_field='slug')), (r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/$', 'archive_day', info_dict), (r'^(?P\d{4})/(?P[a-z]{3})/$', 'archive_month', info_dict), (r'^(?P\d{4})/$', 'archive_year', info_dict), (r'^$', 'archive_index',info_dict), ) - My blog/models.py is: - from django.db import models import datetime # Create your models here. class Entry(models.Model): title = models.CharField(maxlength=255, core=True) pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'pub_date', 'body',)}), ) def __str__(self): return self.title - My template/blog/entry_archive.html is: - {% extends blog_base.html %} {% block content %} {% for object in latest %} {{% object.title %}} {{% object.body %}} {% endfor %} {% endblock %} - I think my problem is that I am calling latest instead of something else . I am not sure what the name for it should be. I tried to define a template_object_name but that raised an error that it was unexpected. Any help would be appreciated. Thanks, Evan --~--~-~--~~~---~--~~ 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: Creating a current path Context Processor
James Bennett wrote: > On 6/3/07, Evan H. Carmi <[EMAIL PROTECTED]> wrote: >> I don't know how to pass the context processor with HttpResponse so my >> template can do the ifequal. If someone can send me in the right >> direction it would be glorious. > > Have a look at the documentation, which covers the fact that you need > to use a slightly different Context class to have context processors > automatically applied: > > http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext > > You'll want to import RequestContext, and do something like > > c = RequestContext(request, { 'posts': entreis }) > > Or import the render_to_response shortcut as well and do it like so: > > return render_to_response('blog/blog_list.html', { 'posts': entries }, > context_instance=RequestContext(request)) > > Also, note that Django includes a context processor which adds the > HttpRequest object to any RequestContext it's used in, so adding > 'django.core.context_processors.request' to your > TEMPLATE_CONTEXT_PROCESSORS setting will get that for you > automatically; then, in a template, you could use {{ request.path }} > to get the path. > Thanks for your help. I eventually got it to work. The request.path only gives the ending of the url e.g. "/blog/" not the full url though? Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Creating a current path Context Processor
Hi, I am trying to follow the DRY principle. For the navigation of my site I want to have a single template. My problem is that I need a way to change the class of the nav links depending on what page is currently being visited. I want to try and do something of this sort: In my template do a ifequal current path to the path the nav links to than this will have the class of nav_here. All the other nav links will have a class of nav_regular. (The specific names of these classes doesn't matter.) On the django IRC channel someone suggested that I use a Context Processor to do this. I am not completely sure how Context Processors work but I tried anyways. In my settings.py I have: #Context Processors TEMPLATE_CONTEXT_PROCESSORS = ( 'binarymanipulations.context_processor', ) In the directory binarymanipulations I have a context_processor.py file with: #Context Processors should live here def CurrentPath(request): return {'current_path': request.path} My views.py is: # Create your views here. from django.shortcuts import HttpResponse from binarymanipulations.blog.models import Entry from django.template import Context, loader, Template from binarymanipulations.context_processor import CurrentPath def index(request): entries = Entry.objects.all().order_by('-pub_date') t = loader.get_template('blog/blog_list.html') c = Context({ 'posts' : entries }) return HttpResponse(t.render(c)) I don't know how to pass the context processor with HttpResponse so my template can do the ifequal. If someone can send me in the right direction it would be glorious. Evan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Creating a Blog: combining seperate parts
Hey, I am attempting to create a blog from scratch (it sounds like a great way to learn something but it is a lot more work if it is the first project you've done.) I have a models.py: - class Entry(models.Model): title = models.CharField(maxlength=255, core=True) pub_date = models.DateTimeField(core=True) slug = models.SlugField(maxlength=30, prepopulate_from= ['title']) body = models.TextField(core=True) class Admin: fields = ( (None, {'fields': ('slug', 'title', 'pub_date', 'body',)}), ) def __str__(self): return self.title - A views.py: - def index(request): latest_values_list = Entry.objects.values() return render_to_response('blog/blog_list.html', {'latest_values_list': latest_values_list}) - A template blog_list.html: - Blog Homepage {{title}} Published on {{pub_date}} {{body}} - My views.py is very wrong. So for now ignore it. I want to have all the data from Entry visible through the template to a web browser. I don't know what is a fast and efficient way to have my views.py deal with the database and then have my template show it. If anyone has any ideas it would be great. Thanks, Evan --~--~-~--~~~---~--~~ 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: Tutorial: Can't see my polls
risomt wrote: > http://binarymanipulations.com:8157/polls/1/vote/ displays the Poll's > title and all of the poll's choices correctly - start from there I am not sure of how to start. I have been looking around with my views and models and templates but as the novice I am, I haven't found anything yet. Should I post some other information? Or can you define how to "start from there" more clearly? > Sorry for the weak answer, but its pretty late. I did notice an error > with your form in poll_detail (http://binarymanipulations.com:8157/ > polls/1/) - should be > I looked at that. My poll_detail.html is: -- {{ poll.question }} {% if error_message %}{{ error_message }}{% endif %} {% for choice in poll.choice_set.all %} {{ choice.choice }} {% endfor %} - So to me it looks as if my form action is how it should be? Thanks, Evan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [EMAIL PROTECTED] 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 -~--~~~~--~~--~--~---
Tutorial: Can't see my polls
Hello, I am running django 0.95. I am going through the tutorial. My problem is this: I have 4 polls. If I run python manage.py shell and Poll.objects.all() it shows them. Unfortunately when I go mysite/polls (http://binarymanipulations.com:8157/polls/) it says "No polls are available." Also if I go to mysite/polls/1 (http://binarymanipulations.com:8157/polls/1/) it shows a vote box but no options. My views.py is http://dpaste.com/8413/ and template for poll_list.html http://dpaste.com/8414/ If anyone can tell me where my grievous error is, I would be very happy. I have asked a little on #django but to no avail. Thanks, Evan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [EMAIL PROTECTED] 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 -~--~~~~--~~--~--~---