Django no such table: project_forum? -
so i'm trying make forum django, keep getting operational error no such table: project_forum. code:
list.html (/visdjango/visdjango/templates/list.html)
<!-- forums --> <div id="list"> <table border="0" cellpadding="4" width="100%"> <tr> <td></td> <td>posts</td> <td>last post</td> <td></td> </tr> {% forum in forums %} <tr> <td {% if forloop.last %}class="last"{% endif %}> <div class="title"> <a href="{% url forum.views.forum forum.pk %}">{{ forum.title }}</a> </div></td> <td {% if forloop.last %}class="last"{% endif %}>{{ forum.num_posts }}</td> <td {% if forloop.last %}class="last"{% endif %}> {{ forum.last_post.short|linebreaksbr }}</td> <td {% if forloop.last %}class="last"{% endif %}> <a class="button" href="{% url forum.views.forum forum.pk %}">view</a> </td> </tr> {% endfor %}
then views.py (visdjango/project/views.py)
def forum(request, pk): return render_to_response('template/forum.html', { 'forums': forum.objects.all() })
models.py (visdjango/project/models.py)
class forum(models.model): title = models.charfield(max_length=60) created = models.datetimefield(auto_now_add=true) def __unicode__(self): return self.title+" - "+self.created def num_posts(self): return sum([t.num_posts() t in self.thread_set.all()]) def last_post(self): if self.thread_set.count(): last = none t in self.thread_set.all(): l = t.last_post() if l: if not last: last = l elif l.created > last.created: last = l return last
finally, in settings.py (visdjango/visdjango/setttings.py)
databases = { 'default': { 'engine': 'django.db.backends.sqlite3', 'name': os.path.join(base_dir, 'db.sqlite3'), } }
sorry long post, thanks
Comments
Post a Comment