Commit 24947cda authored by onny's avatar onny
Browse files

fix add project form

parent 7c7cea0a
......@@ -16,6 +16,13 @@ class ProjectForm(forms.ModelForm):
class Meta:
model = Project
fields = ['artist', 'name', 'city', 'datefrom', 'dateto']
widgets = {
'artist': forms.Select(attrs={'v-model': 'artist.id'}),
'name': forms.TextInput(attrs={'v-model': 'project.name'}),
'city': forms.TextInput(attrs={'v-model': 'project.city'}),
'datefrom': forms.DateTimeInput(attrs={'type': 'date', 'v-model': 'project.datefrom'}),
'dateto': forms.DateTimeInput(attrs={'type': 'date', 'v-model': 'project.dateto'})
}
class EntryForm(forms.ModelForm):
class Meta:
......
......@@ -17,7 +17,7 @@ class ArtistSerializer(serializers.ModelSerializer):
class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = ('id', 'artist', 'name')
fields = ('id', 'artist', 'name', 'city', 'datefrom', 'dateto')
class ProjectReadSerializer(serializers.ModelSerializer):
......
......@@ -22,8 +22,11 @@ var demo = new Vue({
},
addProject: function () {
var newProject = {
artist: this.artist.id,
name: this.project.name.trim(),
artist: this.artist.id
city: this.project.city.trim(),
datefrom: this.project.datefrom,
dateto: this.project.dateto
};
axios
.post('http://127.0.0.1:8000/api/project/', newProject);
......
......@@ -8,24 +8,25 @@
{{ artist_form.as_table }}
</table>
<br>
<button class="btn" v-on:click="addArtist()">Submit</button>
<button type="submit" v-on:click="addArtist()">Submit</button>
</form>
<h2>Create a project</h2>
<form v-on:submit.prevent class="form-group col-sm-8 form-horizontal">
<form v-on:submit.prevent>
<table>
{{ project_form.as_table }}
</table>
<!--
<label class="form-label" for="project">Belongs to artist</label>
<select id="artist" name="artist" v-model="artist.id">
<option v-for="(artist, index) in artist" :value="artist.id" selected>[[ artist.name ]]</option>
</select>
<br>
<label class="form-label" for="name">Name</label>
<input class="form-control" id="name" v-model="project.name">
<input class="form-control" id="name" v-model="project.name"> -->
<br>
<button class="btn" v-on:click="addProject()">Submit</button>
<button type="submit" v-on:click="addProject()">Submit</button>
</form>
<h2>Add an entry</h2>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment