class UserLevel(models.Model):
level = models.ForeignKey(Level, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
progress = models.IntegerField(default=0)
def __str__(self):
return 'user:{}, level:{}, progress:{}'.format(str(self.user), str(self.level), int(self.progress))
@admin.register(UserLevel)
class UserLevelAdmin(admin.ModelAdmin):
pass
class UserLevel(models.Model):
level = models.ForeignKey(Level, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
progress = models.IntegerField(default=0)
def __str__(self):
return str(self.user)
@admin.register(UserLevel)
class UserLevelAdmin(admin.ModelAdmin):
list_display = ('id', 'level', 'progress')
path: '/', component: Blog,
children: [
{path: '/:id?', component: BlogFeed, name: 'blog'},
... ... ...
<template>
<div>
<paginate name="posts" ref="paginator" :list="this.posts" :per="2" class="paginate-list">
<div v-for="post in paginated('posts')" :key="post.id">
<b-card>
<h3><router-link :to="{ name: 'post_detail', params: {id: post.id} }">{{ post.title }}</router-link></h3>
{{ post.body }}
</b-card>
</div>
</paginate>
<paginate-links for="posts"
@change="PageChange"
:show-step-links="true"
>
</paginate-links>
</div>
</template>
<script>
import axios from 'axios'
import { mapGetters } from 'vuex'
export default {
name: 'BlogFeed',
data() {
return {
paginate: ['posts'],
toPage: 2,
}
},
computed: {
...mapGetters([
'posts',
]),
},
methods: {
},
PageChange(toPage, fromPage) {
this.$router.push({path: '/' + toPage})
},
get_posts() {
this.$store.dispatch('GET_POSTS')
}
},
watch: {
$route() {
if (this.$route.path === '/') {
this.$refs.paginator.goToPage(1)
}
}
},
created() {
this.get_posts()
}
}
</script>