I have a many-to-many relationship from my <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="StyleGuideFormsController">
<pre><div ng-bind="examples"></div><pre>
<div ng-bind-html="sgTrustHtml(examples)"></div>
</div>
</div>
model to my Profile
model. If I try to clear and add new skills to a profile, I get Skills
(Python is the first skill to get processed).
I'm not sure what to do, as I'm 100% sure I'm passing model instances to invalid literal for int() with base 10: 'Python'
.
user.profile.skills.add()
答案 0 :(得分:0)
class Control
constructor: (canvas, @control) ->
@control.on('keyup change', ->
update(canvas)
)
skills = ['Python', 'PHP', 'back-end', 'CSS', 'MYSQL']
for s in skills:
try:
skill = Skill.objects.get(name__iexact=s)
except Skill.DoesNotExist:
skill = Skill()
skill.name = s
skill.save()
except Skill.MultipleObjectsReturned:
print "Duplicate skill found: " + s
continue
skills_to_add.append(skill)
if len(skills_to_add):
user.profile.skills.clear()
profile = Profile.objects.get(user_id=user.id)
for obj in skills_to_add:
profile.skills.add(obj)
profile.save()
is a field m2m in your Profile model
skills
答案 1 :(得分:0)
You shouldn't add to if (isset($_GET['AuthorizationJack'])) {
$request_headers[] = "Authorization: Basic ".$_GET['AuthorizationJack'];
}
a list of strings, you should add the list of user.profile.skills
objects.
In other words, use Skill
instead of skills_to_add