Last active
October 10, 2022 20:11
-
-
Save castelhano/bd72947e13421606453798bbf219cc74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FuncionarioForm(forms.ModelForm): | |
class Meta: | |
model = Funcionario | |
fields = ['empresa','matricula','nome','apelido','nome_social','sexo','cargo','regime','data_admissao','data_nascimento','data_desligamento','motivo_desligamento','rg','rg_emissao','rg_orgao_expedidor','cpf','titulo_eleitor','titulo_zona','titulo_secao','reservista','cnh','cnh_categoria','cnh_primeira_habilitacao','cnh_emissao','cnh_validade','foto','fone1','fone2','email','endereco','bairro','cidade','uf','estado_civil','nome_mae','nome_pai','detalhe','usuario','pne'] | |
foto = forms.ImageField(required=False, widget=forms.FileInput(attrs={'class': 'form-control','accept':'image/*'})) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Estou usando a lib cropper.js | |
let croppedCanvas = this.cropper.getCroppedCanvas(); | |
let data = croppedCanvas.toDataURL(); | |
let formInput = document.getElementById('id_foto'); | |
let file = new File([data], `${options?.fileName || 'file'}.png`,{type:"image/png", lastModified: new Date().getTime()}); | |
let container = new DataTransfer(); | |
container.items.add(file); | |
formInput.files = container.files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Funcionario(models.Model): | |
... | |
foto = models.FileField(upload_to='pessoal/fotos/', blank=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment