Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango slugfield database error
    primarykey
    data
    text
    <p>I use django 1.4.</p> <p>I am getting : </p> <p><code>DatabaseError at / no such column: userside_post.slug</code></p> <p>Here, is my <code>model.py</code> :</p> <pre><code>class Post(models.Model): title = models.CharField(max_length = 100) text = models.TextField() slug = models.SlugField(unique=True) def __unicode__(self): return self.title </code></pre> <p>My <code>urls.py</code>:</p> <pre><code>urlpatterns = patterns('userside.views', url(r'^$','index'), url(r'^/(?P&lt;postslug&gt;_*)/$', 'userside.views.singlePost'), ) </code></pre> <p>My <code>views.py</code>:</p> <pre><code>def index(request): post_list = Post.objects.all() return render_to_response('userside/index.html', {'post_list':post_list}, context_instance = RequestContext(request)) def singlePost(request,postslug): post = Post.objects.get(slug=postslug) context = {'post':post} return render_to_response('userside/detail.html',context,context_instance=RequestContext(request)) </code></pre> <p>and my Template file : </p> <pre><code>{% if post_list %} {% for x in post_list %} &lt;p&gt;&lt;a href="/{{ x.slug }}/"&gt;{{ x.title }}&lt;/a&gt;&lt;/p&gt; &lt;p&gt;{{ x.text }}&lt;/p&gt; &lt;hr&gt; {% endfor %} {% else %} &lt;div class="center"&gt;No records! ( but looks like code works correctly!)&lt;/div&gt; {% endif %} </code></pre> <p>and this is manage.py sql userside output : </p> <pre><code>BEGIN; CREATE TABLE "userside_post" ( "id" integer NOT NULL PRIMARY KEY, "title" varchar(100) NOT NULL, "text" text NOT NULL, "slug" varchar(50) NOT NULL UNIQUE ) ; COMMIT; </code></pre> <p>but the PRAGMA table_info() OUTPUT IS :</p> <pre><code>0|id|integer|1||1 1|title|varchar(100)|1||0 2|text|text|1||0 </code></pre> <p>What I am trying to do is, using slug on urls. sth-like-this</p> <p>and last thing ; </p> <p>I want prepopulated_fields for generate slugs automatically by posts title which, needs django admin. </p> <p>But in my project I am not going to use django's admin. I am coding a new admin page.</p> <p>What can I do for this ?</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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