Commit 4924a5361725c83b0edfde1b720aa023bfbeb446
1 parent
4c06a9c5
Exists in
master
and in
3 other branches
changed category model
Showing
3 changed files
with
27 additions
and
7 deletions
Show diff stats
categories/forms.py
... | ... | @@ -4,8 +4,5 @@ from .models import Category |
4 | 4 | class CategoryForm(forms.ModelForm): |
5 | 5 | class Meta: |
6 | 6 | model = Category |
7 | - fields = ('category_father', 'name', 'description', 'visible', 'coordinators', ) | |
8 | - widgets = { | |
9 | - 'category_father': forms.Select(), | |
10 | - | |
11 | - } | |
12 | 7 | \ No newline at end of file |
8 | + fields = ( 'name', 'description', 'visible', 'coordinators', ) | |
9 | + | |
13 | 10 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +# Generated by Django 1.10 on 2016-12-26 16:58 | |
3 | +from __future__ import unicode_literals | |
4 | + | |
5 | +from django.db import migrations, models | |
6 | + | |
7 | + | |
8 | +class Migration(migrations.Migration): | |
9 | + | |
10 | + dependencies = [ | |
11 | + ('categories', '0002_auto_20161223_1504'), | |
12 | + ] | |
13 | + | |
14 | + operations = [ | |
15 | + migrations.RemoveField( | |
16 | + model_name='category', | |
17 | + name='category_father', | |
18 | + ), | |
19 | + migrations.AlterField( | |
20 | + model_name='category', | |
21 | + name='name', | |
22 | + field=models.CharField(max_length=100, unique=True, verbose_name='Name'), | |
23 | + ), | |
24 | + ] | ... | ... |
categories/models.py
... | ... | @@ -6,8 +6,7 @@ from users.models import User |
6 | 6 | class Category(models.Model): |
7 | 7 | """Represents a Course """ |
8 | 8 | |
9 | - category_father = models.ForeignKey('Category', related_name =_("category_parent"), on_delete = models.CASCADE, null = True, blank = True) | |
10 | - name = models.CharField(_("Name"), max_length = 100, blank=False, null=False) | |
9 | + name = models.CharField(_("Name"), max_length = 100, blank=False, null=False, unique= True) | |
11 | 10 | slug = AutoSlugField(_("Slug"),populate_from='name',unique=True) |
12 | 11 | description = models.CharField(_("description"), max_length = 300) |
13 | 12 | visible = models.BooleanField(_("visible")) | ... | ... |