Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Insumo(models.Model):
- nombre = models.CharField(max_length=50)
- file = models.FileField()
- def __str__(self):
- return self.nombre
- class ImportData(ModelForm):
- class Meta:
- model = Insumo
- fields = ['nombre', 'file']
- def carga_data(request):
- if request.method == 'POST':
- formulario = ImportData(request.POST, request.FILES)
- if formulario.is_valid():
- name=request.POST.get('nombre')
- ruta=request.POST.get('file')
- print (name)
- print (ruta)
- return render(request,"carga_data.html", {'form': formulario})
- else:
- formulario = ImportData()
- return render(request, "carga_data.html",{'form': formulario})
- <form method="POST" enctype="multipart/form-data"> {% csrf_token %}
- {{form.as_p}}
- <input type="submit" value="Cargar Informacion">
- </form>
Add Comment
Please, Sign In to add comment