Post Error

8 views
Skip to first unread message

SUBHABRATA BANERJEE

unread,
May 20, 2015, 4:23:44 AM5/20/15
to django...@googlegroups.com
Dear Group,

I was trying to write a RestDjango Application with the help of a web based book available
from https://www.safaribooksonline.com/library/view/lightweight-django/9781491946275/ch04.html

Project's folder structure is as follows,
tutoriall/
  tutoriall/
    migrations/
       _init_.py
   _init_.py
   admin.py
   models.py
   serializers.py
   tests.py
   views.py
   
  quickstart/
   __init__.py
   settings.py
   urls.py
   wsgi.py
 
  db.sqlite3
  manage.py

I am writing the tutoriall/tutoriall/serializer.py as follows:

from rest_framework import serializers
from .models import Sprint

class SprintSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Sprint
        #fields = ('id','name','description')
        fields = ('name','description')



I am writing tutoriall/tutoriall/models.py as follows:
from django.db import models

# Create your models here.
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _

from django.utils.translation import ugettext_lazy as _


class Sprint(models.Model):
    """Development iteration period."""

    name = models.CharField(max_length=100, blank=True, default='')
    description = models.TextField(blank=True, default='')
    end = models.DateField(unique=True)

    def __unicode__(self):
        return self.name or _('Sprint ending %s') % self.end

class Task(models.Model):
    """Unit of work to be done for the sprint."""

    STATUS_TODO = 1
    STATUS_IN_PROGRESS = 2
    STATUS_TESTING = 3
    STATUS_DONE = 4

    STATUS_CHOICES = (
        (STATUS_TODO, _('Not Started')),
        (STATUS_IN_PROGRESS, _('In Progress')),
        (STATUS_TESTING, _('Testing')),
        (STATUS_DONE, _('Done')),
    )

    name = models.CharField(max_length=100)
    description = models.TextField(blank=False, default='')
    sprint = models.ForeignKey(Sprint, blank=True, null=True)
    status = models.SmallIntegerField(choices=STATUS_CHOICES, default=STATUS_TODO)
    order = models.SmallIntegerField(default=0)
    assigned = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True)
    started = models.DateField(blank=True, null=True)
    due = models.DateField(blank=True, null=True)
    completed = models.DateField(blank=True, null=True)

    def __unicode__(self):
        return self.name


I am writing tutoriall/tutoriall/views.py as follows:

from django.shortcuts import render
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from models import Sprint
from serializers import SprintSerializer

class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all()
    serializer_class = SprintSerializer

I am writing tutoriall/quickstart/urls.py as follows:

from django.contrib import admin
from django.conf.urls import url, include
from rest_framework import routers
from quickstart import views
from rest_framework.authtoken.views import obtain_auth_token
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
#Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/token/', obtain_auth_token, name='api-token')
    ]


As I am running it I am getting the command as,
C:\Python27\Lib\site-packages\django\tutoriall>python ./manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
May 20, 2015 - 13:44:01
Django version 1.8.1, using settings 'tutoriall.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.


I am getting the screen as this:
Given as attached .docx file.

but as I am trying to post I am getting the following error.
Request Method:     POST
Request URL:     http://127.0.0.1:8000/users/
Django Version:     1.8.1
Exception Type:     OperationalError
Exception Value:    

no such table: quickstart_sprint



I have slightly changed few names of folders, and I am using Python2.7+ on Windows 7 Professional.

If any one may kindly suggest the error I am doing.

Regards,
Subhabrata Banerjee.






Reply all
Reply to author
Forward
0 new messages