Skip to content

Instantly share code, notes, and snippets.

class Match(models.Model):
WHITE = 'White',
BLACK = 'Black',
DRAW = 'Draw',
UNDETERMINED = 'Undetermined'
MATCH_RESULT_CHOICES = (
(WHITE, 'White Won'),
(BLACK, 'Black Won'),
<template>
<div id="register-tournament">
<input type="text" v-model="tournamentName"/>
<button type="button" v-on:click="createTournament">Create Tournament</button>
</div>
</template>
<script>
import axios from 'axios';
import Vue from 'vue';
import Vuex from 'vuex';
import axios from 'axios';
import createPersistedState from 'vuex-persistedstate';
Vue.use(Vuex)
export const store = new Vuex.Store({
// plugins: [createPersistedState()],
state: {
<template>
<div id="register-tournament">
<input type="text" v-model="tournamentName"/>
<button type="button" v-on:click="createTournament">Create Tournament</button>
<div id="tournament-created" v-if="createdTournamentName">
<p>{{ createdTournamentName }} has been created</p>
<router-link to='/register-players'><button type="button">Proceed to add players >> </button></router-link>
</div>
</div>
</template>
<template>
<div id="register-players">
<h2>Tournament: {{ tournamentName }}</h2>
<div id="add-players" v-if="!playersRegistered">
<input type="text" v-model="playerName" />
<button type="button" @click="addPlayer">Add player</button>
<div id="temporary-player-list">
<ul>
<li v-for="player in temporaryPlayerList">{{ player }}</li>
</ul>
actions : {
createTourney (context, payload) {
return new Promise (resolve, reject) {
// prepare data to be sent
axios({
// mthod,url, data....
validateStatus: function (status) {
return (status >= 200 && status < 300) || (status === 400)
}
}).then(response => {
@Attila03
Attila03 / FK.py
Created February 19, 2018 05:37
Django bulk insert with Foreign Key
from stocks import wsgi
from django.core.exceptions import ObjectDoesNotExist
from api.models import Stock, Company
import csv
csvpath = r'prices.csv'
batch_size = 500
t1 = time.time()
import pandas as pd
import numpy as np
def add_individual_rows():
heights = range(150, 211)
satisfaction_baseline = 150
d = {}
l = []
df = pd.DataFrame(columns=['height', 'satisfaction'])
for h in heights: