Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Django-rest

I trying to setup DJango restframework in a windows machine and I get the following error when I run the code,

Steps done.

  1. Downloaded rest-framework & other utilities from github
  2. Using easy_install I installed all the packages.

    Here is the confirmation msg,

    C:\Python27\Scripts>easy_install django-rest Searching for django-rest Best match: django-rest 0.0.1 Processing django_rest-0.0.1-py2.7.egg django-rest 0.0.1 is already the active version in easy-install.pth

    Using c:\python27\lib\site-packages\django_rest-0.0.1-py2.7.egg Processing dependencies for django-rest Finished processing dependencies for django-rest

  3. Created a new project firstwebservice which created all the files.

  4. Edited settings.py file and included django rest as given below,

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'rest_framework',
        # Uncomment the next line to enable the admin:
        # 'django.contrib.admin',
        # Uncomment the next line to enable admin documentation:
        # 'django.contrib.admindocs',
    )
    
  5. Ran the project

    Error:-No module named rest_framework...
    
like image 655
user1050619 Avatar asked Feb 08 '13 16:02

user1050619


People also ask

Is Django GOOD FOR REST API?

Django REST framework (DRF) is a powerful and flexible toolkit for building Web APIs. Its main benefit is that it makes serialization much easier. Django REST framework is based on Django's class-based views, so it's an excellent option if you're familiar with Django.

How does Django REST Framework work?

REST is a loosely defined protocol for listing, creating, changing, and deleting data on your server over HTTP. The Django REST framework (DRF) is a toolkit built on top of the Django web framework that reduces the amount of code you need to write to create REST interfaces.


2 Answers

is rest_framework actually installed and on your PYTHONPATH?

That looks like a basic import error.

Suggest you:

Double check everything's installed correctly, by running "manage.py shell" and trying both "import rest_framework" and "from rest_framework import authtoken".

I would install with pip not easy if you can, easy has given me many issues like this before.

sudo pip install djangorestframework
like image 58
Glyn Jackson Avatar answered Sep 18 '22 12:09

Glyn Jackson


You're installing the wrong package. The package is named djangorestframework, not django-rest.

like image 42
Tom Christie Avatar answered Sep 20 '22 12:09

Tom Christie