wzy 6 months ago
parent 3631f5ca24
commit 26ca8e87b4

@ -1,14 +1,3 @@
"""
Django settings for djangoProject2 project.
Generated by 'django-admin startproject' using Django 5.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

@ -1,9 +1,9 @@
from django.contrib import admin
from django.urls import path,include
from.views import index,star
urlpatterns = [
path('admin/', admin.site.urls),
path('',index),

@ -1,5 +1,3 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys

@ -0,0 +1,112 @@
# Generated by Django 5.0.6 on 2024-06-02 04:11
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Genre',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, verbose_name='类型')),
],
options={
'verbose_name': '电影类型',
'verbose_name_plural': '电影类型',
'db_table': 'Genre',
},
),
migrations.CreateModel(
name='Movie',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256, verbose_name='电影名')),
('imdb_id', models.IntegerField(verbose_name='imdb_id')),
('time', models.CharField(blank=True, max_length=256, verbose_name='时长')),
('release_time', models.CharField(blank=True, max_length=256, verbose_name='发行时间')),
('intro', models.TextField(blank=True, verbose_name='简介')),
('director', models.CharField(blank=True, max_length=256, verbose_name='导演')),
('actor', models.CharField(blank=True, max_length=256, verbose_name='演员')),
('writers', models.CharField(blank=True, max_length=256, verbose_name='编剧')),
('genre', models.ManyToManyField(to='movie.genre', verbose_name='类型')),
],
options={
'verbose_name': '电影信息',
'verbose_name_plural': '电影信息',
'db_table': 'Movie',
},
),
migrations.CreateModel(
name='Movie_hot',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('rating_number', models.IntegerField(verbose_name='评分人数')),
('movie', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movie.movie', verbose_name='电影名')),
],
options={
'verbose_name': '最热电影',
'verbose_name_plural': '最热电影',
'db_table': 'Movie_hot',
},
),
migrations.CreateModel(
name='Movie_rating',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('score', models.FloatField(verbose_name='评分')),
('comment', models.TextField(blank=True, verbose_name='评论')),
('movie', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movie.movie', verbose_name='电影')),
],
options={
'verbose_name': '电影评分信息',
'verbose_name_plural': '电影评分信息',
'db_table': 'Movie_rating',
},
),
migrations.CreateModel(
name='Movie_similarity',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('similarity', models.FloatField(verbose_name='相似度')),
('movie_source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='movie_source', to='movie.movie')),
('movie_target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='movie_target', to='movie.movie')),
],
options={
'verbose_name': '电影相似度',
'verbose_name_plural': '电影相似度',
},
),
migrations.AddField(
model_name='movie',
name='movie_similarity',
field=models.ManyToManyField(through='movie.Movie_similarity', to='movie.movie', verbose_name='相似电影'),
),
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128, unique=True, verbose_name='用户名')),
('password', models.CharField(max_length=256, verbose_name='密码')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='邮箱')),
('rating_movies', models.ManyToManyField(through='movie.Movie_rating', to='movie.movie')),
],
options={
'verbose_name': '用户信息',
'verbose_name_plural': '用户信息',
'db_table': 'Usser',
},
),
migrations.AddField(
model_name='movie_rating',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movie.user', verbose_name='用户'),
),
]

@ -16,4 +16,5 @@ urlpatterns=[
path('detail/<int:pk>',views.MovieDetailView.as_view(),name='detail'),
path('history/<int:pk>',views.RatingHistoryView.as_view(),name='history'),
path('del_rec/<int:pk>',views.delete_recode,name='delete_recode'),
path('recommend',views.RecommendMovieView.as_view(),name='recommend')
]

@ -260,6 +260,7 @@ class MovieDetailView(DetailView):
template_name='movie/detail.html'
context_object_name = 'movie'
def get_context_data(self,**kwargs):
global user_id
context=super().get_context_data(**kwargs)
login=True
try:

File diff suppressed because one or more lines are too long

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="shortcut icon" href="{%static'movie/favicon1.ico'%}"/>
<link rel="bookmark" href="{%static'movie/favicon1.ico'%}"/>
<meta charset="UTF-8">
<title>电影推荐系统</title>
<script> src="http://cdn.bootcss.com/jquery/11.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="{%static'bootstrap/css/bootstrap.css'%}">
<link rel="sstylesheet" href="/static/bootstrap/js/jquery.min.js">
<link rel="stylesheet" href="{%static/bootstrap/js/bootstrap.min.js">
</head>
<body>
</body>
</html>
Loading…
Cancel
Save