This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
from .models import SentimentAnalysisInference | |
import nltk.sentiment.vader import SentimentIntensityAnalyzer | |
class SentimentAnalysisInferenceSerializer(serializers.ModelSerializer): | |
username = serializers.CharField(source='user.username',read_only=True) | |
class Meta : | |
model = SentimentAnalysisInference | |
fields = ['username','text','result'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import User | |
class SentimentAnalysisInference(models.Model): | |
user = models.OneTOneField(User,on_delete=models.CASCADE) | |
text = models.TextField() | |
result = models.CharField(max_length=255) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest-framework import serializers | |
from .models import Review | |
class ReviewSerializer(serializers.Serializer): | |
class Meta : | |
model = Review | |
fields = ['username','content'] | |
# to validate any field override the function validate_<field> | |
def validate_username(self,value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Review(models.Model): | |
username = models.CharField(max_length=255) | |
content = models.TextField() | |
def __str__(self): | |
return '{username} => {content}'.format(username=self.username,content=self.content) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# installed app | |
INSTALLED_APPS = [ | |
# ... | |
'Inference', | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.urls import path | |
from rest_framework_jwt.views import obtain_jwt_token,refresh_jwt_token | |
from django.conf.urls.static import static | |
from django.conf import settings | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('',include('infrence.urls')), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Delete Inference</title> | |
</head> | |
<body> | |
<h3> Are you sure about deleting {{object.title}} product</h3> | |
<form action='POST' >{% csrf_token %} | |
<input type='submit' value='sure' /> or <a href='/' >forget</a> | |
</form> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Update Inference</title> | |
</head> | |
<body> | |
<div> | |
<form method='POST' enctype="multipart/form-data"> {% csrf_token %} | |
{{form.media}} | |
{{form.as_p}} | |
<input type="submit" value="update" > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>create Inference</title> | |
</head> | |
<body> | |
<div> | |
<form method='POST' enctype="multipart/form-data"> {% csrf_token %} | |
{{form.media}} | |
{{form.as_p}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Inference Detail</tile> | |
</head> | |
<body> | |
<div> | |
<img src='{{inference_obj.image.url}}' /> | |
<h3>Prediction => {{inference_obj.prediction}}</h3> | |
</div> |