daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TIMEZONES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
  2.  
  3.     time_zone = models.CharField(max_length=100, blank=True, null=True, choices=TIMEZONES)
  4.      
  5. class Lesson(models.Model):
  6.     user = models.ForeignKey(User, null=True, default=None, related_name='lessons', on_delete=models.CASCADE)
  7.     lesson_instrument = models.CharField(max_length=255, choices=instrument_list, blank=True)
  8.     lesson_level = models.CharField(max_length=255, choices=level_list, blank=True)
  9.     lesson_length = models.CharField(max_length=255, choices=length_list, blank=True)
  10.     lesson_datetime = models.DateTimeField(null=True, blank=True)
  11.     lesson_weekly = models.BooleanField(default=False, blank=True)
  12.      
  13. def new_lesson(request):
  14.     if request.method == 'POST':
  15.         form = LessonForm(request.POST)
  16.  
  17.         if form.is_valid():
  18.             lessons = form.save(commit=False)
  19.             lessons.user = request.user
  20.             lessons.save()
  21.             messages.success(request,'Lesson successfully created')
  22.             return redirect('/teacher/schedule')
  23.  
  24.         else:
  25.             messages.error(request, 'Information entered was invalid')
  26.  
  27.     else:
  28.         form = LessonForm()
  29.  
  30.     form = LessonForm()
  31.     lessons = Lesson.objects.filter(user=request.user)
  32.     context = {'form' : form, 'lessons': lessons}
  33.     return render(request, 'teacher/new_lesson.html', context)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top