Hi Jani!
Am Sonntag, 18. Juni 2017 11:05:27 UTC+2 schrieb Jani Tiainen:
Thanks! Good to know that I'm not completely wrong :-)
That's where the first problem starts. Like I said I'm not that much familiar with database stuff.
That doesn't tell me anything :-(
I know what test driven development is, but don't understand the context with this.
Sadly in that example (http://blog.e-shell.org/130) it's not clear what to put where. Maybe you can help me with that.
That's easy: polls\models.py which starts with
("User" because of creator and maintainer)
But polls\forms.py is change several times.
Then
And then
But here's "import ProjectForm" instead of import "Project" and "class Meta" is missing.
Can you tell me what I did wrong?
Thank you!
-- Am Sonntag, 18. Juni 2017 11:05:27 UTC+2 schrieb Jani Tiainen:
Hi,Seems that you've on right track. Just don't chew up too big bites.
Thanks! Good to know that I'm not completely wrong :-)
I suggest that first you start mapping your real world ideas to models. Don't worry if you don't get it right at first try thats why migrations do exist.
That's where the first problem starts. Like I said I'm not that much familiar with database stuff.
Also test driven development model could work nicely.
That doesn't tell me anything :-(
I know what test driven development is, but don't understand the context with this.
Most of the things you describe are clienside operations and Django being agnostic for that you're free to implement clientside as you wish.You probably won't find much for similar project but there might be solutions to individual problems.
Sadly in that example (http://blog.e-shell.org/130) it's not clear what to put where. Maybe you can help me with that.
class Project(models.Model): name = models.CharField('Name of the project', max_length=100) code = models.CharField('Code number of the project', max_length=10) creator = models.ForeignKey(User, related_name='created_projects') maintainer = models.ManyToManyField(User, related_name='maintained_projects')
That's easy: polls\models.py which starts with
from django.db import models
from django.contrib.auth.models import User
("User" because of creator and maintainer)
But polls\forms.py is change several times.
#from myproject.myapp.models import Project from .models import Project
class ProjectForm(forms.ModelForm): class Meta: model = Proyecto
Then
#from myproject.myapp.models import Project
from .models import Project from django.contrib.auth.models import Group class ProjectForm(forms.ModelForm): creator_choices = [(c.id, c.username) for c in Group.objects.get(name__icontains='creator').user_set.all()] maintainer_choices = [(m.id, m.username) for m in Group.objects.get(name__icontains='maintainer').user_set.all()] creator = forms.ChoiceField(required=True, label='Project creator', choices=creator_choices) maintainer = forms.MultipleChoiceField(required=True, label='Project maintainer(s)', choices=maintainer_choices) class Meta: model = Proyecto
And then
#from myproject.myapp.forms import ProjectForm
from .forms import ProjectForm from django.contrib.auth.models import Group creator_choices = [(c.id, c.username) for c in Group.objects.get(name__icontains='creator').user_set.all()] maintainer_choices = [(m.id, m.username) for m in Group.objects.get(name__icontains='maintainer').user_set.all()] creator = forms.ChoiceField(required=True, label='Project creator', choices=creator_choices) maintainer = forms.MultipleChoiceField(required=True, label='Project maintainer(s)', choices=maintainer_choices) myform = ProjectForm() myform.fields['creator'].choices = creator_choices myform.fields['maintainer'].choices = maintainer_choices
But here's "import ProjectForm" instead of import "Project" and "class Meta" is missing.
Can you tell me what I did wrong?
python manage.py makemigrations always can't find something (project, ProjectForm, ...), no matter what I'm trying to change to resolve that error. I'm completely confused :-(Thank you!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/91a2c682-a360-49a5-80ad-d287da0e30e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment