You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Profile for One

Name One
Email Address n/a
Posts4
  • Data is not displayed in the templates
    Board » Django » Templates
    I have a template that I want to use to display all users in the system:

    <html>
    <head>
    <title>
    List all Users
    </title>
    </head>
    <body>
    <table border="1">
    <tr><td><b>ID</b></td><td><b>Name</b></td><td><b>E-mail address</b></td></tr>
    {% for u in User.objects.all %}
    <tr><td> {{ u.id }} </td><td> {{ u.name }} </td><td> {{ u.email }} </td><td>&nbsp;</td></tr>
    {% endfor %}
    {{User.objects.all}}
    </table>
    </body>
    </html>

    However, when I visit the page, it only displays the header row with "Name", "E-mail address", etc. and it does not display the actual user data, even though User.objects.all() works from the Python console.

    I have another template which I want to display just one user at a time:

    {% user = User.objects.filter(id=u) %}
    <html>
    <head>
    <title>
    View user {{ user.id }}
    </title>
    </head>
    <body>
    <table>
    <tr><td>User ID</td><td>{{user.id}}</td></tr>
    <tr><td>User Name</td><td>{{user.name}}</td></tr>
    <tr><td>User E-mail</td><td>{{user.email}}</td></tr>
    <tr><td>Date/Time joined</td><td>{{user.date}}</td></tr>
    </table>
    </body>
    </html>

    The view for this template is:

    def user(request, u):
    return render_to_response('micropost/user.html', {'u': u})

    However, when I try to view this page, I get an error that says "Invalid block tag: 'user'" and it highlights line 1.
  • CSRF token missing or incorrect
    Board » Django » Views
    I am getting an error saying "CSRF token missing or incorrect" even though I put a "{% csrf_token %}" tag in the form. Below is the form I use to post data:

    <html>
    <head>
    <title>
    Sign up
    </title>
    </head>
    <body>
    <form method="POST" action="/signup/">
    {% csrf_token %}
    Name: <input type="text" /><br />
    E-mail address: <input type="email" /><br />
    Password: <input type="password" /><br />
    <input type="submit" value="Submit" />
    </form>
    </body>
    </html>

    I don't know if my browser is accepting cookies or how to verify it, but I got the same error in both internet explorer and google chrome.

  • Re: No module named django.core
    Board » Getting Started » Django Installation
    Never mind. I got it working. I had to explicitly call the version of python assocated with django instead of the verson independently installed.
  • No module named django.core
    Board » Getting Started » Django Installation
    I recently installed Django on Windows Vista and tried starting the tutorial at https://docs.djangoproject.com/en/1.4/intro/tutorial01/ . One problem is that when I enter "django-admin.py startproject mysite", I get an error that says:

    Traceback (most recent call last):
    File "C:\Program Files\BitNami DjangoStack\apps\django\django\bin\django-admin
    .py", line 2, in <module>
    from django.core import management
    ImportError: No module named django.core

    even though I added "C:\Program Files\BitNami DjangoStack\apps\django\django\bin\;" to my path variable.

    Another problem is that when I enter '"C:\Program Files\BitNami DjangoStack\apps\django\django\bin\django-admin.py" startproject mysite', I get an error that says:

    File "C:\Program Files\BitNami DjangoStack\apps\django\django\bin\django-admin
    .py", line 2, in <module>
    from django.core import management
    ImportError: No module named django.core


Powered by Sphene Community Tools