Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I write a form in django
    primarykey
    data
    text
    <p>I am writing a forums app for my final project in class and I am trying to write a form for creating a new thread, Basically all I need it to do is </p> <p>username: text box here</p> <p>Name of thread: Text box here</p> <p>Post: text box here</p> <p>I want to do this in forms.py instead of making a template for it.</p> <pre><code>url(r"^(.+)/new_thread/$", new_thread, name="thread_new_thread"), </code></pre> <p>That's my url thread</p> <pre><code>def list_threads(request, forum_slug): """Listing of threads in a forum.""" threads = Thread.objects.filter(forum__slug=forum_slug).order_by("-created") threads = mk_paginator(request, threads, 20) template_data = {'threads': threads, 'forum_slug': forum_slug} return render_to_response("forum/list_threads.html", template_data, context_instance=RequestContext(request)) </code></pre> <p>That is my list_threads view, I have a button that should link to the forms.py version of my new thread post</p> <pre><code>class Thread(models.Model): title = models.CharField(max_length=60) slug = models.SlugField(max_length=60) created = models.DateTimeField(auto_now_add=True) creator = models.ForeignKey(User, blank=True, null=True) forum = models.ForeignKey(Forum) class Meta: unique_together = ('slug', 'forum', ) def save(self, *args, **kwargs): self.slug = slugify(self.title) super(Thread, self).save(*args, **kwargs) def get_absolute_url(self): return reverse('forum_list_posts', args=[self.forum.slug, self.slug]) def __unicode__(self): return unicode(self.creator) + " - " + self.title def num_posts(self): return self.post_set.count() def num_replies(self): return self.post_set.count() - 1 def last_post(self): if self.post_set.count(): return self.post_set.order_by("created")[0] </code></pre> <p>This is my thread model</p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload