views.py
def notesadd(request):
    form = NoteForm(request.POST or None)
    if form.is_valid():
        form.save()
        form=NoteForm()
    context = {
        'form': form
    }
    print('submitted')
       
    return render(request, 'notes.html', context)



models.py
    class Notes(models.Model):
    sharewith = models.ManyToManyField(User, blank=True, null=True)
    subject = models.CharField(max_length=10, null=True)
    uploadingdate = models.DateTimeField(null=True)
    notesfile = models.FileField(null=True)
    description = models.TextField(max_length=50,null=True)
   
def __str__(self):
  return self.sharewith.user.username

forms.py

class NoteForm(forms.ModelForm):
    class Meta:
        model=Notes
        fields = [
    'sharewith' ,
    'subject',
    'uploadingdate',
   'notesfile',
    'description' ]

notes.html

 {% extends 'navigation.html' %}

 {% block body %}

<form method="post" novalidate>
  {% csrf_token %}

 
  
 <div class="container my-4">

  <div class="form-group row">
    <label for="Subject" class="col-sm-2 col-form-label">Subject:</label>
    <div class="col-sm-10">
    {{note.subject}}
      <input type="Subject" class="form-control"  placeholder="Subject">
    </div>
  </div>


  <div class="form-group">
    <label for="exampleFormControlTextarea1">Description:</label>
    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
></textarea>
  </div>
  

  <div class="form-group row">
    <label for="inputfile" class="col-sm-2 col-form-label">Choose Notes:</
label>
    <div class="col-sm-10">
      <input type="file" class="form-control" id="inputFiletype" placeholder
="Enter type of file">
    </div>
  </div>




<div class="form-group">
    <label for="exampleFormControlSelect1">Share With</label>
    <select class="form-control" id="exampleFormControlSelect1">
      <option>{{form.username}}</option>
     
    </select>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>

 </div>

</form> 
 {% endblock  %}



admin.py
from django.contrib import admin

from .models import Notes

admin.site.register(Notes)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c669fa9c-a4ec-45ed-8409-abe85ce5982do%40googlegroups.com.

Reply via email to