Skip to content

Instantly share code, notes, and snippets.

@Nipun2016
Last active February 9, 2018 06:01
Show Gist options
  • Save Nipun2016/3990df99d9a649215a8950b2d396e9bb to your computer and use it in GitHub Desktop.
Save Nipun2016/3990df99d9a649215a8950b2d396e9bb to your computer and use it in GitHub Desktop.
content_type = ContentType.objects.get_for_model(MODEL_NAME)
// primary key of the object in this case it was the project id
object_id = current_project.pk
FileAttachment.objects.create(content_type=content_type,
object_id=object_id,
file_type='project_image',
attachment_file=request.FILES.get('project_image'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment