def bunked(request): """ Create the bunk, return the user to the main page. """ to = request.POST['to'] if to == 'default': return bunk_form(request) to_user = get_object_or_404(User, pk=to) from_user = request.user time = timezone.now() new_bunk = Bunk(from_user=from_user, to_user=to_user, time=time) new_bunk.save() return index(request)
import django django.setup() from bunk.models import Bunk from django.contrib.auth.models import User from django.utils import timezone import random for i in range(10000): people = random.sample(set(User.objects.all()), 2) b = Bunk(from_user=people[0], to_user=people[1], time=timezone.now()) b.save()
def bunkem(request, user_id): b = Bunk(bunkFrom=request.user, bunkTo=User.objects.get(pk=user_id)) b.save() return HttpResponseRedirect(reverse("bunk:personalFeed", args=(User.objects.get(pk=user_id).id,)))