Admin interface and API
In order to manage the data of the application, the admin interface and an API point can be set. From the admin panel we can see both the movie's data, and the user registered, writing the following admin.py
file:
from django.contrib import admin from books_recsys_app.models import MovieData,UserProfile class MoviesAdmin(admin.ModelAdmin): list_display = ['title', 'description'] admin.site.register(UserProfile) admin.site.register(MovieData,MoviesAdmin)
After setting the corresponding admin
URL on the urls.py
file:
url(r'^admin/', include(admin.site.urls))
We should see our admin panel (at http://localhost:8000/admin/
) with the two models and the data within the models resembles the fields specified in the admin.py
file:
To set the API endpoint to retrieve the data for each registered user, first we need to write out serializers.py
specifying which fields of the UserProfile
model we want to employ:
from books_recsys_app.models import UserProfile from rest_framework...